-
-
Notifications
You must be signed in to change notification settings - Fork 829
Fix not_in
search with deep nesting
#1537
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
eafb922
to
4566158
Compare
@clgiovannelli I've incorporated your changes into #1561 as I'm dealing with the complex scenario that requires multiple interconnected changes from your PR, #1279, and my own to be applied at the same time. I also added additional test coverage. Tell me if you're ok with that. |
Thank you for taking the time to look into this. I'll check your changes today. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes the not_in
search functionality with deep nesting by addressing an issue where generated SQL queries for excluding articles based on associated tags were incorrect. The fix modifies the query structure to use proper joins instead of subqueries, improving both correctness and performance.
- Adds support for HABTM associations between comments and tags
- Implements logic to handle table aliases in through reflections correctly
- Adds comprehensive test coverage for negative conditions on HABTM associations
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
File | Description |
---|---|
spec/support/schema.rb | Adds HABTM relationship between comments and tags with join table |
spec/ransack/search_spec.rb | Uncomments previously pending test for published articles |
spec/ransack/adapters/active_record/base_spec.rb | Adds comprehensive test cases for negative conditions with HABTM associations |
lib/ransack/nodes/condition.rb | Implements core fix for table alias handling and nested condition detection |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
@giovannelli can this be closed now #1561 is merged? |
Thank you! |
Great! Thank you for getting back to me @giovannelli 🤝 |
Description
This pull request addresses issue #1411, where the generated SQL query for excluding articles based on associated tags was incorrect (I've used tags the my example).
The current query joins and filters tags improperly, resulting in an unintended query structure. Specifically, the subquery logic used for filtering tags produces incorrect results and may impact performance.
The solution modifies the query structure to use proper joins and filtering, simplifying the SQL and ensuring correct results.