mirror of
https://github.com/github/rails.git
synced 2026-01-30 08:48:06 -05:00
Performance enhancement for Base.exists?. CLoses #8769. [hasmanyjosh]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7274 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
@@ -447,7 +447,7 @@ module ActiveRecord #:nodoc:
|
||||
# Person.exists?(:name => "David")
|
||||
# Person.exists?(['name LIKE ?', "%#{query}%"])
|
||||
def exists?(id_or_conditions)
|
||||
!find(:first, :conditions => expand_id_conditions(id_or_conditions)).nil?
|
||||
!find(:first, :select => "#{table_name}.#{primary_key}", :conditions => expand_id_conditions(id_or_conditions)).nil?
|
||||
rescue ActiveRecord::ActiveRecordError
|
||||
false
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user