Prefix primary key with table name so it works as part of a joined fetch
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1086 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
parent
2cfe309dc4
commit
9e799e731c
@ -318,7 +318,7 @@ def find(*args)
|
||||
when 0
|
||||
raise RecordNotFound, "Couldn't find #{name} without an ID#{conditions}"
|
||||
when 1
|
||||
if result = find(:first, options.merge({ :conditions => "#{primary_key} = #{sanitize(ids.first)}#{conditions}" }))
|
||||
if result = find(:first, options.merge({ :conditions => "#{table_name}.#{primary_key} = #{sanitize(ids.first)}#{conditions}" }))
|
||||
return expects_array ? [ result ] : result
|
||||
else
|
||||
raise RecordNotFound, "Couldn't find #{name} with ID=#{ids.first}#{conditions}"
|
||||
@ -326,7 +326,7 @@ def find(*args)
|
||||
else
|
||||
# Find multiple ids
|
||||
ids_list = ids.map { |id| sanitize(id) }.join(',')
|
||||
result = find(:all, options.merge({ :conditions => "#{primary_key} IN (#{ids_list})#{conditions}", :order => primary_key }))
|
||||
result = find(:all, options.merge({ :conditions => "#{table_name}.#{primary_key} IN (#{ids_list})#{conditions}", :order => primary_key }))
|
||||
if result.size == ids.size
|
||||
return result
|
||||
else
|
||||
|
Loading…
Reference in New Issue
Block a user