Skip to content
This repository
Browse code

Performance enhancement for Base.exists?. CLoses #8769. [hasmanyjosh]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7274 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
commit c4c6662498cb85feb407ccb86d8694e38f439f31 1 parent 73f72ee
Michael Koziarski authored August 05, 2007

Showing 1 changed file with 1 addition and 1 deletion. Show diff stats Hide diff stats

  1. 2  activerecord/lib/active_record/base.rb
2  activerecord/lib/active_record/base.rb
@@ -447,7 +447,7 @@ def find_by_sql(sql)
447 447
       #   Person.exists?(:name => "David")
448 448
       #   Person.exists?(['name LIKE ?', "%#{query}%"])
449 449
       def exists?(id_or_conditions)
450  
-        !find(:first, :conditions => expand_id_conditions(id_or_conditions)).nil?
  450
+        !find(:first, :select => "#{table_name}.#{primary_key}", :conditions => expand_id_conditions(id_or_conditions)).nil?
451 451
       rescue ActiveRecord::ActiveRecordError
452 452
         false
453 453
       end

0 notes on commit c4c6662

Please sign in to comment.
Something went wrong with that request. Please try again.