mirror of
https://github.com/github/rails.git
synced 2026-01-29 00:08:15 -05:00
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
This commit is contained in:
@@ -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}"
|
||||
|
||||
Reference in New Issue
Block a user