Permalink
Browse files

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
  • Loading branch information...
1 parent 71bdf13 commit ff1db4de5f291baef70ba637101bed35d79c4b86 @dhh dhh committed Apr 13, 2005
@@ -156,7 +156,7 @@ def construct_sql
"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 @@ def delete_records(records)
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 @@ def construct_sql
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 @@ def construct_sql
@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 @@ def target_obsolete?
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 @@ def type_condition
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.

0 comments on commit ff1db4d

Please sign in to comment.