aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record
diff options
context:
space:
mode:
authorErnie Miller <ernie@metautonomo.us>2011-02-12 13:59:53 -0500
committerSantiago Pastorino <santiago@wyeworks.com>2011-02-12 19:52:12 -0200
commitd72add9c20778e253f90fbfe587eae0e205c40ad (patch)
tree8f182a77fc6b83bd3cadafc150165ad3615c215a /activerecord/lib/active_record
parente2b99eb1a77b1b2d8c1ede5239a2f72ef0898cd0 (diff)
downloadrails-d72add9c20778e253f90fbfe587eae0e205c40ad.tar.gz
rails-d72add9c20778e253f90fbfe587eae0e205c40ad.tar.bz2
rails-d72add9c20778e253f90fbfe587eae0e205c40ad.zip
Fix table name collision due to incorrect alias count on certain joins.
[#6423 state:committed] Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r--activerecord/lib/active_record/associations/class_methods/join_dependency/join_association.rb8
1 files changed, 4 insertions, 4 deletions
diff --git a/activerecord/lib/active_record/associations/class_methods/join_dependency/join_association.rb b/activerecord/lib/active_record/associations/class_methods/join_dependency/join_association.rb
index 3fea24ebf8..856d826d67 100644
--- a/activerecord/lib/active_record/associations/class_methods/join_dependency/join_association.rb
+++ b/activerecord/lib/active_record/associations/class_methods/join_dependency/join_association.rb
@@ -82,12 +82,12 @@ module ActiveRecord
connection = active_record.connection
name = connection.table_alias_for "#{pluralize(reflection.name)}_#{parent_table_name}#{suffix}"
- table_index = aliases[name] + 1
- name = name[0, connection.table_alias_length-3] + "_#{table_index}" if table_index > 1
+ aliases[name] += 1
+ name = name[0, connection.table_alias_length-3] + "_#{aliases[name]}" if aliases[name] > 1
+ else
+ aliases[name] += 1
end
- aliases[name] += 1
-
name
end