diff options
author | Rick Olson <technoweenie@gmail.com> | 2006-03-27 08:09:36 +0000 |
---|---|---|
committer | Rick Olson <technoweenie@gmail.com> | 2006-03-27 08:09:36 +0000 |
commit | ed6c3c17f79bd4b5ad91e2473193551e3441769e (patch) | |
tree | 85759ef2b2f19e606fe77fdb89bcba229d864bea /activerecord | |
parent | 445cb5c08d4eea7bd035e86d1f38ae258c635e88 (diff) | |
download | rails-ed6c3c17f79bd4b5ad91e2473193551e3441769e.tar.gz rails-ed6c3c17f79bd4b5ad91e2473193551e3441769e.tar.bz2 rails-ed6c3c17f79bd4b5ad91e2473193551e3441769e.zip |
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
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/CHANGELOG | 2 | ||||
-rwxr-xr-x | activerecord/lib/active_record/associations.rb | 4 |
2 files changed, 4 insertions, 2 deletions
diff --git a/activerecord/CHANGELOG b/activerecord/CHANGELOG index 39095ac1f5..944c4acf2a 100644 --- a/activerecord/CHANGELOG +++ b/activerecord/CHANGELOG @@ -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] diff --git a/activerecord/lib/active_record/associations.rb b/activerecord/lib/active_record/associations.rb index dcb0f31684..116e5fb5e2 100755 --- a/activerecord/lib/active_record/associations.rb +++ b/activerecord/lib/active_record/associations.rb @@ -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 |