diff options
author | Ryuta Kamizono <kamipo@gmail.com> | 2016-08-06 21:00:46 +0900 |
---|---|---|
committer | Ryuta Kamizono <kamipo@gmail.com> | 2016-08-06 21:00:46 +0900 |
commit | 320996a7e5dbf0014b37cfc4d2259c88a4092744 (patch) | |
tree | 1752966f5cea3ecc69e899586fcd935d3c481da7 /activerecord/lib | |
parent | 04d0e3c30b877a75cd7e82d3d41422b879a17e64 (diff) | |
download | rails-320996a7e5dbf0014b37cfc4d2259c88a4092744.tar.gz rails-320996a7e5dbf0014b37cfc4d2259c88a4092744.tar.bz2 rails-320996a7e5dbf0014b37cfc4d2259c88a4092744.zip |
Revert passing arel node with splat binds for `where`
Passing arel node with splat binds for `where` was introduced at #22877
for uniqueness validator supports prepared statement. But I'd not like
to introduce the following usage:
```ruby
Foo.where(arel, *binds)
```
I'd like to revert this internal usage.
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/relation/where_clause_factory.rb | 1 | ||||
-rw-r--r-- | activerecord/lib/active_record/validations/uniqueness.rb | 7 |
2 files changed, 5 insertions, 3 deletions
diff --git a/activerecord/lib/active_record/relation/where_clause_factory.rb b/activerecord/lib/active_record/relation/where_clause_factory.rb index dbf172a577..a81ff98e49 100644 --- a/activerecord/lib/active_record/relation/where_clause_factory.rb +++ b/activerecord/lib/active_record/relation/where_clause_factory.rb @@ -22,7 +22,6 @@ module ActiveRecord parts = predicate_builder.build_from_hash(attributes) when Arel::Nodes::Node parts = [opts] - binds = other else raise ArgumentError, "Unsupported argument type: #{opts} (#{opts.class})" end diff --git a/activerecord/lib/active_record/validations/uniqueness.rb b/activerecord/lib/active_record/validations/uniqueness.rb index 58273509be..8c4930a81d 100644 --- a/activerecord/lib/active_record/validations/uniqueness.rb +++ b/activerecord/lib/active_record/validations/uniqueness.rb @@ -76,8 +76,11 @@ module ActiveRecord else klass.connection.case_sensitive_comparison(table, attribute, column, value) end - bind = Relation::QueryAttribute.new(attribute_name, value, cast_type) - klass.unscoped.where!(comparison, bind) + klass.unscoped.tap do |scope| + parts = [comparison] + binds = [Relation::QueryAttribute.new(attribute_name, value, cast_type)] + scope.where_clause += Relation::WhereClause.new(parts, binds) + end end def scope_relation(record, relation) |