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

Don't remove join dependencies in Relation#exists?

Fixes #18632
This commit is contained in:
Sean Griffin 2015-01-23 12:04:13 -07:00
parent 2698e18757
commit b9d668f8cb
3 changed files with 13 additions and 1 deletions

View file

@ -1,3 +1,9 @@
* Don't remove join dependencies in `Relation#exists?`
Fixes #18632
*Sean Griffin*
* Invalid values assigned to a JSON column are assumed to be `nil`.
Fixes #18629.

View file

@ -307,7 +307,7 @@ module ActiveRecord
relation = relation.where(conditions)
else
unless conditions == :none
relation = where(primary_key => conditions)
relation = relation.where(primary_key => conditions)
end
end

View file

@ -857,6 +857,12 @@ class RelationTest < ActiveRecord::TestCase
assert ! fake.exists?(authors(:david).id)
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
authors = Author.all
assert_equal authors(:bob), authors.last