aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2006-07-07 17:34:45 +0000
committerJeremy Kemper <jeremy@bitsweat.net>2006-07-07 17:34:45 +0000
commit230c5a060ba7fe3ac2f78f5975debd04e85167cb (patch)
treee76a53c68fd29b674abb6fb1f1be5768b76b25c1 /activerecord
parent69d8ca4c525bfbf1ca617ea196aae2f29a3d0513 (diff)
downloadrails-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')
-rwxr-xr-xactiverecord/lib/active_record/base.rb5
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}"