提交 b9d668f8 编写于 作者: S Sean Griffin

Don't remove join dependencies in `Relation#exists?`

Fixes #18632
上级 2698e187
* Don't remove join dependencies in `Relation#exists?`
Fixes #18632
*Sean Griffin*
* Invalid values assigned to a JSON column are assumed to be `nil`. * Invalid values assigned to a JSON column are assumed to be `nil`.
Fixes #18629. Fixes #18629.
......
...@@ -307,7 +307,7 @@ def exists?(conditions = :none) ...@@ -307,7 +307,7 @@ def exists?(conditions = :none)
relation = relation.where(conditions) relation = relation.where(conditions)
else else
unless conditions == :none unless conditions == :none
relation = where(primary_key => conditions) relation = relation.where(primary_key => conditions)
end end
end end
......
...@@ -857,6 +857,12 @@ def test_exists ...@@ -857,6 +857,12 @@ def test_exists
assert ! fake.exists?(authors(:david).id) assert ! fake.exists?(authors(:david).id)
end end
def test_exists_uses_existing_scope
post = authors(:david).posts.first
authors = Author.includes(:posts).where(name: "David", posts: { id: post.id })
assert authors.exists?(authors(:david).id)
end
def test_last def test_last
authors = Author.all authors = Author.all
assert_equal authors(:bob), authors.last assert_equal authors(:bob), authors.last
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册