mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Whether a column exists or not doesn't affect whether we can use binds
Looking through the blame, this logic used to be when we actually created the bind tuple. My guess is that `nil` couldn't be handled there at that time. It can, now.
This commit is contained in:
parent
76d7d95790
commit
40887135f6
2 changed files with 4 additions and 7 deletions
|
@ -959,12 +959,9 @@ module ActiveRecord
|
|||
|
||||
def create_binds(opts)
|
||||
bindable, non_binds = opts.partition do |column, value|
|
||||
case value
|
||||
when String, Integer, ActiveRecord::StatementCache::Substitute
|
||||
@klass.columns_hash.include? column.to_s
|
||||
else
|
||||
false
|
||||
end
|
||||
value.is_a?(String) ||
|
||||
value.is_a?(Integer) ||
|
||||
value.is_a?(ActiveRecord::StatementCache::Substitute)
|
||||
end
|
||||
|
||||
association_binds, non_binds = non_binds.partition do |column, value|
|
||||
|
|
|
@ -42,7 +42,7 @@ module ActiveRecord
|
|||
end
|
||||
|
||||
def test_association_not_eq
|
||||
expected = Comment.arel_table[@name].not_eq('hello')
|
||||
expected = Comment.arel_table[@name].not_eq(Arel::Nodes::BindParam.new)
|
||||
relation = Post.joins(:comments).where.not(comments: {title: 'hello'})
|
||||
assert_equal(expected.to_sql, relation.where_values.first.to_sql)
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue