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:
parent
29b54a41d9
commit
06d518a323
1 changed files with 5 additions and 3 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue