mirror of
https://github.com/github/rails.git
synced 2026-01-24 05:48:09 -05:00
Qualify the ids used such that eager loading can avoid ambigious keys
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1163 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
@@ -156,7 +156,7 @@ module ActiveRecord
|
||||
"j.#{@association_class_primary_key_name} = #{@owner.quoted_id} "
|
||||
|
||||
@finder_sql << " AND #{interpolate_sql(@options[:conditions])}" if @options[:conditions]
|
||||
@finder_sql << "ORDER BY #{@order}" if @order
|
||||
@finder_sql << " ORDER BY #{@order}" if @order
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -112,7 +112,7 @@ module ActiveRecord
|
||||
else
|
||||
ids = quoted_record_ids(records)
|
||||
@association_class.update_all(
|
||||
"#{@association_class_primary_key_name} = NULL",
|
||||
"#{@association_class.table_name}.#{@association_class_primary_key_name} = NULL",
|
||||
"#{@association_class_primary_key_name} = #{@owner.quoted_id} AND #{@association_class.primary_key} IN (#{ids})"
|
||||
)
|
||||
end
|
||||
@@ -126,7 +126,7 @@ module ActiveRecord
|
||||
if @options[:finder_sql]
|
||||
@finder_sql = interpolate_sql(@options[:finder_sql])
|
||||
else
|
||||
@finder_sql = "#{@association_class_primary_key_name} = #{@owner.quoted_id}"
|
||||
@finder_sql = "#{@association_class.table_name}.#{@association_class_primary_key_name} = #{@owner.quoted_id}"
|
||||
@finder_sql << " AND #{interpolate_sql(@conditions)}" if @conditions
|
||||
end
|
||||
|
||||
@@ -136,7 +136,7 @@ module ActiveRecord
|
||||
@options[:counter_sql] = @options[:finder_sql].gsub(/SELECT (.*) FROM/i, "SELECT COUNT(*) FROM")
|
||||
@counter_sql = interpolate_sql(@options[:counter_sql])
|
||||
else
|
||||
@counter_sql = "#{@association_class_primary_key_name} = #{@owner.quoted_id}"
|
||||
@counter_sql = "#{@association_class.table_name}.#{@association_class_primary_key_name} = #{@owner.quoted_id}"
|
||||
@counter_sql << " AND #{interpolate_sql(@conditions)}" if @conditions
|
||||
end
|
||||
end
|
||||
|
||||
@@ -46,7 +46,7 @@ module ActiveRecord
|
||||
end
|
||||
|
||||
def construct_sql
|
||||
@finder_sql = "#{@association_class_primary_key_name} = #{@owner.quoted_id}#{@options[:conditions] ? " AND " + @options[:conditions] : ""}"
|
||||
@finder_sql = "#{@association_class.table_name}.#{@association_class_primary_key_name} = #{@owner.quoted_id}#{@options[:conditions] ? " AND " + @options[:conditions] : ""}"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -737,7 +737,7 @@ module ActiveRecord #:nodoc:
|
||||
condition << "OR #{table_name}.#{inheritance_column} = '#{subclass.name.demodulize}' "
|
||||
end
|
||||
|
||||
return " (#{type_condition})"
|
||||
return " (#{type_condition}) "
|
||||
end
|
||||
|
||||
# Guesses the table name, but does not decorate it with prefix and suffix information.
|
||||
|
||||
Reference in New Issue
Block a user