1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

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.
This commit is contained in:
Ryuta Kamizono 2016-08-06 21:00:46 +09:00
parent 04d0e3c30b
commit 320996a7e5
2 changed files with 5 additions and 3 deletions

View file

@ -22,7 +22,6 @@ module ActiveRecord
parts = predicate_builder.build_from_hash(attributes) parts = predicate_builder.build_from_hash(attributes)
when Arel::Nodes::Node when Arel::Nodes::Node
parts = [opts] parts = [opts]
binds = other
else else
raise ArgumentError, "Unsupported argument type: #{opts} (#{opts.class})" raise ArgumentError, "Unsupported argument type: #{opts} (#{opts.class})"
end end

View file

@ -76,8 +76,11 @@ module ActiveRecord
else else
klass.connection.case_sensitive_comparison(table, attribute, column, value) klass.connection.case_sensitive_comparison(table, attribute, column, value)
end end
bind = Relation::QueryAttribute.new(attribute_name, value, cast_type) klass.unscoped.tap do |scope|
klass.unscoped.where!(comparison, bind) parts = [comparison]
binds = [Relation::QueryAttribute.new(attribute_name, value, cast_type)]
scope.where_clause += Relation::WhereClause.new(parts, binds)
end
end end
def scope_relation(record, relation) def scope_relation(record, relation)