diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2006-07-07 17:34:45 +0000 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2006-07-07 17:34:45 +0000 |
commit | 230c5a060ba7fe3ac2f78f5975debd04e85167cb (patch) | |
tree | e76a53c68fd29b674abb6fb1f1be5768b76b25c1 /activerecord/lib | |
parent | 69d8ca4c525bfbf1ca617ea196aae2f29a3d0513 (diff) | |
download | rails-230c5a060ba7fe3ac2f78f5975debd04e85167cb.tar.gz rails-230c5a060ba7fe3ac2f78f5975debd04e85167cb.tar.bz2 rails-230c5a060ba7fe3ac2f78f5975debd04e85167cb.zip |
find_one uses find_every.first instead of find_initial since its primary key constraint obviates find_initial's :limit => 1. References #5635.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4578 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/lib')
-rwxr-xr-x | activerecord/lib/active_record/base.rb | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb index 812f30c773..1c8c819efa 100755 --- a/activerecord/lib/active_record/base.rb +++ b/activerecord/lib/active_record/base.rb @@ -981,7 +981,10 @@ module ActiveRecord #:nodoc: conditions = " AND (#{sanitize_sql(options[:conditions])})" if options[:conditions] options.update :conditions => "#{table_name}.#{primary_key} = #{quote(id,columns_hash[primary_key])}#{conditions}" - if result = find_initial(options) + # Use find_every(options).first since the primary key condition + # already ensures we have a single record. Using find_initial adds + # a superfluous :limit => 1. + if result = find_every(options).first result else raise RecordNotFound, "Couldn't find #{name} with ID=#{id}#{conditions}" |