Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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 NZKoz authored
Showing with 1 addition and 1 deletion.
  1. +1 −1  activerecord/lib/active_record/base.rb
2  activerecord/lib/active_record/base.rb
View
@@ -447,7 +447,7 @@ def find_by_sql(sql)
# 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
Please sign in to comment.
Something went wrong with that request. Please try again.