Fix nested conditions, polymorphic associations handling
Fix nested conditions, polymorphic associations handling
This PR addresses several issues with Ransack's handling of polymorphic associations and negative predicates:
Key Improvements
-
Polymorphic Association Support: Added proper handling for polymorphic associations in correlated subqueries by correctly managing both foreign key and type columns.
-
Negative Predicate Handling: Fixed the behavior of negative predicates (
not_null,not_cont, etc.) when used with associations:-
not_null: true/falsenow generates the correct IN/NOT IN queries -
not_contnow properly generates NOT IN queries with LIKE conditions
-
-
Complex AND Conditions: Improved extraction of correlated keys from complex AND conditions with multiple children.
-
String Wildcard Handling: Added proper quoting for string values containing wildcards (%) in LIKE predicates.
-
Nested Condition Detection: Added helper method to correctly identify nested vs. non-nested conditions.
Tests Added
- Tests for wildcard string handling in LIKE/NOT LIKE predicates
- Tests for negative conditions on associations
- Tests for nested condition identification
- Comprehensive tests for polymorphic associations with not_in predicate
- Tests for complex AND conditions with multiple children
Other Changes
- Removed pending status from a previously failing test that now passes
- Added
.ideato.gitignore
This PR fixes issues with complex queries involving polymorphic associations and negative predicates, which previously generated incorrect SQL.
This PR incorporates changes from #1537 and #1279.