未验证 提交 6c98dad5 编写于 作者: R Ryuta Kamizono 提交者: GitHub

Merge pull request #34329 from r7kamura/feature/where-exclamation-consistency

Ignore empty condition on #construct_relation_for_exists
......@@ -363,7 +363,7 @@ def construct_relation_for_exists(conditions)
case conditions
when Array, Hash
relation.where!(conditions)
relation.where!(conditions) unless conditions.empty?
else
relation.where!(primary_key => conditions) unless conditions == :none
end
......
......@@ -246,6 +246,10 @@ def test_exists_with_nil_arg
assert_equal true, Topic.first.replies.exists?
end
def test_exists_with_empty_hash_arg
assert_equal true, Topic.exists?({})
end
# Ensure +exists?+ runs without an error by excluding distinct value.
# See https://github.com/rails/rails/pull/26981.
def test_exists_with_order_and_distinct
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册