Fixed eager loading so that an aliased table cannot clash with a has_and_belongs_to_many join table [Rick]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4066 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
Rick Olson
2006-03-27 08:09:36 +00:00
parent 445cb5c08d
commit ed6c3c17f7
2 changed files with 4 additions and 2 deletions

View File

@@ -1,5 +1,7 @@
*SVN*
* Fixed eager loading so that an aliased table cannot clash with a has_and_belongs_to_many join table [Rick]
* Add support for :include to with_scope [andrew@redlinesoftware.com]
* Support the use of public synonyms with the Oracle adapter; required ruby-oci8 v0.1.14 #4390 [schoenm@earthlink.net]

View File

@@ -1367,7 +1367,8 @@ module ActiveRecord
table_index = join_dependency.table_aliases[aliased_table_name]
@aliased_table_name = @aliased_table_name[0..active_record.connection.table_alias_length-3] + "_#{table_index+1}" if table_index > 0
end
join_dependency.table_aliases[aliased_table_name] += 1
if reflection.macro == :has_and_belongs_to_many || (reflection.macro == :has_many && reflection.options[:through])
@aliased_join_table_name = reflection.macro == :has_and_belongs_to_many ? reflection.options[:join_table] : reflection.through_reflection.klass.table_name
unless join_dependency.table_aliases[aliased_join_table_name].zero?
@@ -1377,7 +1378,6 @@ module ActiveRecord
end
join_dependency.table_aliases[aliased_join_table_name] += 1
end
join_dependency.table_aliases[aliased_table_name] += 1
end
def association_join