49bcb00 has changed to maintain extra joins only if other table's
condition is found (e.g. `other_table[:id].eq(table[:foreign_id])`).
It means that cannot maintain extra joins for complex conditions
(especially "(... OR ...)"), so it has caused a regression #37167.
This changes to maintain extra joins for complex conditions too like as
before.
Fixes#37167.
This fixes a bug that the `foreign_key` and the `foreign_type` are
separated as different table conditions if a polymorphic association has
a scope that joins another tables.
This reverts commit 9a1abedcde, reversing
changes made to c72d6c91a7.
Conflicts:
activerecord/CHANGELOG.md
activerecord/test/models/comment.rb
This change break integration with activerecord-deprecated_finders so
I'm reverting until we find a way to make it work with this gem.
Changed the call to a scope block to be evaluated with instance_eval.
The result is that ScopeRegistry can use the actual class instead of base_class when
caching scopes so queries made by classes with a common ancestor won't leak scopes.