Permalink
Browse files

Return false for exists? with new records - fixes #6199.

(cherry picked from commit fa21b73)
  • Loading branch information...
pixeltrix committed May 10, 2012
1 parent 66e338a commit 62f098dddf55a36e15c94a60b29c3c280b219cce
@@ -185,9 +185,8 @@ def all(*args)
# Person.exists?(['name LIKE ?', "%#{query}%"])
# Person.exists?
def exists?(id = false)
- return false if id.nil?
-
id = id.id if ActiveRecord::Base === id
+ return false if id.nil?
join_dependency = construct_join_dependency_for_association_find
relation = construct_relation_for_association_find(join_dependency)
@@ -32,6 +32,7 @@ def test_exists
assert Topic.exists?(:author_name => "Mary", :approved => true)
assert Topic.exists?(["parent_id = ?", 1])
assert !Topic.exists?(45)
+ assert !Topic.exists?(Topic.new)
begin
assert !Topic.exists?("foo")
@@ -599,6 +599,7 @@ def test_exists
assert ! davids.exists?(authors(:mary).id)
assert ! davids.exists?("42")
assert ! davids.exists?(42)
+ assert ! davids.exists?(davids.new)
fake = Author.where(:name => 'fake author')
assert ! fake.exists?

0 comments on commit 62f098d

Please sign in to comment.