aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/relation/where_clause.rb
diff options
context:
space:
mode:
authorRyuta Kamizono <kamipo@gmail.com>2018-05-07 02:26:31 +0900
committerRyuta Kamizono <kamipo@gmail.com>2019-02-18 00:41:43 +0900
commit49bcb008cbaf0fa2db727ae58e7e27015a7ae02c (patch)
treee626fb51981577b56b849af5194ec64e797543a7 /activerecord/lib/active_record/relation/where_clause.rb
parent25b3cbb241a334d750eed24f5094151e52ed7c69 (diff)
downloadrails-49bcb008cbaf0fa2db727ae58e7e27015a7ae02c.tar.gz
rails-49bcb008cbaf0fa2db727ae58e7e27015a7ae02c.tar.bz2
rails-49bcb008cbaf0fa2db727ae58e7e27015a7ae02c.zip
Fix eager loading polymorphic association with mixed table conditions
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.
Diffstat (limited to 'activerecord/lib/active_record/relation/where_clause.rb')
-rw-r--r--activerecord/lib/active_record/relation/where_clause.rb6
1 files changed, 1 insertions, 5 deletions
diff --git a/activerecord/lib/active_record/relation/where_clause.rb b/activerecord/lib/active_record/relation/where_clause.rb
index e225628bae..47728aac30 100644
--- a/activerecord/lib/active_record/relation/where_clause.rb
+++ b/activerecord/lib/active_record/relation/where_clause.rb
@@ -140,11 +140,7 @@ module ActiveRecord
def except_predicates(columns)
predicates.reject do |node|
- case node
- when Arel::Nodes::Between, Arel::Nodes::In, Arel::Nodes::NotIn, Arel::Nodes::Equality, Arel::Nodes::NotEqual, Arel::Nodes::LessThan, Arel::Nodes::LessThanOrEqual, Arel::Nodes::GreaterThan, Arel::Nodes::GreaterThanOrEqual
- subrelation = (node.left.kind_of?(Arel::Attributes::Attribute) ? node.left : node.right)
- columns.include?(subrelation.name.to_s)
- end
+ Arel.fetch_attribute(node) { |attr| columns.include?(attr.name.to_s) }
end
end