aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib
diff options
context:
space:
mode:
authorSean Griffin <sean@seantheprogrammer.com>2017-07-18 13:43:25 -0400
committerGitHub <noreply@github.com>2017-07-18 13:43:25 -0400
commita12ce5d44782d08211fd6bbb9919207d9106f63a (patch)
tree8cbdbe138f13a0dc7c3666f036fda685c644d262 /activerecord/lib
parentf47bac481949a69a519ea7d833e1a8d435332d52 (diff)
parent36ff7b63ec083924a5b407cf3df7ae90e22183e2 (diff)
downloadrails-a12ce5d44782d08211fd6bbb9919207d9106f63a.tar.gz
rails-a12ce5d44782d08211fd6bbb9919207d9106f63a.tar.bz2
rails-a12ce5d44782d08211fd6bbb9919207d9106f63a.zip
Merge pull request #29780 from MaxLap/fix_unscope_where_column_with_or
Bugfix: unscope(where: [columns]) would not remove the correct binds
Diffstat (limited to 'activerecord/lib')
-rw-r--r--activerecord/lib/active_record/relation/where_clause.rb3
1 files changed, 2 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/relation/where_clause.rb b/activerecord/lib/active_record/relation/where_clause.rb
index 0feb2c6cb2..731f161eb1 100644
--- a/activerecord/lib/active_record/relation/where_clause.rb
+++ b/activerecord/lib/active_record/relation/where_clause.rb
@@ -136,10 +136,11 @@ module ActiveRecord
binds_index = 0
predicates = self.predicates.reject do |node|
+ binds_contains = node.grep(Arel::Nodes::BindParam).size if node.is_a?(Arel::Nodes::Node)
+
except = \
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
- binds_contains = node.grep(Arel::Nodes::BindParam).size
subrelation = (node.left.kind_of?(Arel::Attributes::Attribute) ? node.left : node.right)
columns.include?(subrelation.name.to_s)
end