mirror of
https://github.com/activerecord-hackery/ransack.git
synced 2022-11-09 13:47:45 -05:00
Query for negative associations as subquery
When a collection association (has_many, etc) is searched for negative conditions (NOT...), a JOIN will still include other rows that match. The implied meaning is that it should only select where *none* of the associations match, but the actual result still selects records where *any* of the joined associations match. This implementation removes joins that were added while building the conditions and moves them into a subquery if needed.
This commit is contained in:
parent
eb8257092a
commit
96d0fd75ad
6 changed files with 178 additions and 22 deletions
|
@ -27,6 +27,8 @@ module Ransack
|
|||
@join_dependency = join_dependency(@object)
|
||||
@join_type = options[:join_type] || Polyamorous::OuterJoin
|
||||
@search_key = options[:search_key] || Ransack.options[:search_key]
|
||||
@associations_pot = {}
|
||||
@lock_associations = []
|
||||
|
||||
if ::ActiveRecord::VERSION::STRING >= Constants::RAILS_4_1
|
||||
@base = @join_dependency.join_root
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue