Ticket #10605: using_select_value.diff
| File using_select_value.diff, 0.9 kB (added by protocool, 6 months ago) |
|---|
-
activerecord/lib/active_record/base.rb
old new 548 548 # Person.exists?(:name => "David") 549 549 # Person.exists?(['name LIKE ?', "%#{query}%"]) 550 550 def exists?(id_or_conditions) 551 !find(:first, :select => "#{quoted_table_name}.#{primary_key}", 552 :conditions => expand_id_conditions(id_or_conditions)).nil? 551 !connection.select_value( 552 construct_finder_sql(:select => "#{quoted_table_name}.#{primary_key}", 553 :conditions => expand_id_conditions(id_or_conditions), :limit => 1), 554 "#{name} Exists" 555 ).nil? 553 556 end 554 557 555 558 # Creates an object (or multiple objects) and saves it to the database, if validations pass.