Skip to content

Conversation

@gdott9
Copy link

@gdott9 gdott9 commented Oct 29, 2025

Description

When a condition in the advanced search hash has an empty value, the condition is not removed so the "LEFT OUTER JOIN" is added to the SQL query without a "WHERE" clause.

Problem

The behavior is not the same when using a simple condition hash (example: {children_name_eq: ''}) versus using an advanced search hash (example: {c: {'0' => {a: ['children_name'], p: 'eq', v: ['']}}}).

The first example results in the following query :

SELECT "people".* FROM "people" ORDER BY "people"."id" DESC

The second example results in the following query :

SELECT "people".* FROM "people" LEFT OUTER JOIN "people" "children_people" ON "children_people"."parent_id" = "people"."id" ORDER BY "people"."id" DESC

Proposed solution

I added code to remove conditions with a blank value in the same way it is done with the simple condition.
Do you see a better way to handle this ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant