-
-
Notifications
You must be signed in to change notification settings - Fork 829
Description
When passing a hash of query parameters to ransack, the documentation states that nil predicate values will be ignored. However, empty string values for predicates are also ignored. For example,
{
"nameIn": [""],
"addressIn": ["123 Fake St."]
}
If we apply the query params above to a fictional User model, the generated query would be:
SELECT `users`.* FROM `users` WHERE ((`users`.`address` IN ('123 Fake St.'));
Additionally, the same behavior occurs when passing empty string into Eq clauses. Based on the documentation, I would expect the following query to be generated:
SELECT `users`.* FROM `users` WHERE ((`users`.`address` IN ('123 Fake St.') AND `users`.`name` IN (''));
If this is not the desired case, then including this in the documentation would be preferred. If a user was specifying an Eq clause against Ids and (through some method) empty string ends up as the predicate value, the result set would go from 1 (in the case of Eq) to N (all records, since the idEq clause would be dropped for empty string).