Query with predicates defined with 'not_in' arel predicate results with an error "TypeError: can't quote Array"
activerecord-5.2.2/lib/active_record/connection_adapters/abstract/quoting.rb:179:in `_quote'
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.
[Fixes#504]
The right-hand side of an IN predicate does not always respond
to :val. For example, it might be a subquery, represented by
a SelectManager.
This is a patch to address a regression in v1.6.0
caused by a missing test on a fix, and probably
needs a deeper look.
TODO: Put the test in a more logical place.