提交 1a4d13b8 编写于 作者: S Sergey Alekseev

Remove duplicated parameter check on #where!

It seems that #where! is not designed to be used as a chained where.
See initial implementation at 8c2c6051.
So, no need to check twice.

We should not test #where!

https://github.com/rails/rails/pull/15285#discussion_r13018316
上级 a6f55fe2
......@@ -573,15 +573,11 @@ def where(opts = :chain, *rest)
end
end
def where!(opts = :chain, *rest) # :nodoc:
if opts == :chain
WhereChain.new(self)
else
references!(PredicateBuilder.references(opts)) if Hash === opts
def where!(opts, *rest) # :nodoc:
references!(PredicateBuilder.references(opts)) if Hash === opts
self.where_values += build_where(opts, rest)
self
end
self.where_values += build_where(opts, rest)
self
end
# Allows you to change a previously set where condition for a given attribute, instead of appending to that condition.
......
......@@ -99,7 +99,7 @@ def test_chaining_multiple
assert_bound_ast value, Post.arel_table[@name], Arel::Nodes::NotEqual
assert_equal 'ruby on rails', bind.last
end
def test_rewhere_with_one_condition
relation = Post.where(title: 'hello').where(title: 'world').rewhere(title: 'alone')
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册