diff options
author | Sean Griffin <sean@thoughtbot.com> | 2015-01-25 17:30:42 -0700 |
---|---|---|
committer | Sean Griffin <sean@thoughtbot.com> | 2015-01-25 17:30:42 -0700 |
commit | d6110799c2573080897410f9836f5aa623b197ea (patch) | |
tree | bfbfc983b3f8558d8dd85a042354c8eb59f333b9 /activerecord/lib/active_record/relation/query_methods.rb | |
parent | 7227e4fba17f4a50e53a5486a3b956a6c7c26697 (diff) | |
download | rails-d6110799c2573080897410f9836f5aa623b197ea.tar.gz rails-d6110799c2573080897410f9836f5aa623b197ea.tar.bz2 rails-d6110799c2573080897410f9836f5aa623b197ea.zip |
Move `where_unscoping` logic over to `WhereClause`
Diffstat (limited to 'activerecord/lib/active_record/relation/query_methods.rb')
-rw-r--r-- | activerecord/lib/active_record/relation/query_methods.rb | 19 |
1 files changed, 2 insertions, 17 deletions
diff --git a/activerecord/lib/active_record/relation/query_methods.rb b/activerecord/lib/active_record/relation/query_methods.rb index c21730e6ae..1568064e18 100644 --- a/activerecord/lib/active_record/relation/query_methods.rb +++ b/activerecord/lib/active_record/relation/query_methods.rb @@ -410,9 +410,8 @@ module ActiveRecord raise ArgumentError, "Hash arguments in .unscope(*args) must have :where as the key." end - Array(target_value).each do |val| - where_unscoping(val) - end + target_values = Array(target_value).map(&:to_s) + self.where_clause = where_clause.except(*target_values) end else raise ArgumentError, "Unrecognized scoping: #{args.inspect}. Use .unscope(where: :attribute_name) or .unscope(:order), for example." @@ -916,20 +915,6 @@ module ActiveRecord self.send(unscope_code, result) end - def where_unscoping(target_value) - target_value = target_value.to_s - - self.where_values = where_values.reject do |rel| - case rel - when Arel::Nodes::Between, Arel::Nodes::In, Arel::Nodes::NotIn, Arel::Nodes::Equality, Arel::Nodes::NotEqual, Arel::Nodes::LessThanOrEqual, Arel::Nodes::GreaterThanOrEqual - subrelation = (rel.left.kind_of?(Arel::Attributes::Attribute) ? rel.left : rel.right) - subrelation.name.to_s == target_value - end - end - - self.bind_values = bind_values.reject { |col,_| col.name == target_value } - end - def custom_join_ast(table, joins) joins = joins.reject(&:blank?) |