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

stop recursively calling exists?

This commit is contained in:
Aaron Patterson 2010-11-05 11:48:40 -07:00
parent 29b54a41d9
commit 06d518a323

View file

@ -171,14 +171,16 @@ module ActiveRecord
def exists?(id = nil)
id = id.id if ActiveRecord::Base === id
relation = select(primary_key).limit(1)
case id
when Array, Hash
where(id).exists?
relation = relation.where(id)
else
relation = select(primary_key).limit(1)
relation = relation.where(primary_key.eq(id)) if id
relation.first ? true : false
end
relation.first ? true : false
end
protected