Skip to content
This repository
Browse code

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
  • Loading branch information...
commit ed6c3c17f79bd4b5ad91e2473193551e3441769e 1 parent 445cb5c
risk danger olson authored March 27, 2006
2  activerecord/CHANGELOG
... ...
@@ -1,5 +1,7 @@
1 1
 *SVN*
2 2
 
  3
+* Fixed eager loading so that an aliased table cannot clash with a has_and_belongs_to_many join table [Rick]
  4
+
3 5
 * Add support for :include to with_scope [andrew@redlinesoftware.com]
4 6
 
5 7
 * Support the use of public synonyms with the Oracle adapter; required ruby-oci8 v0.1.14 #4390 [schoenm@earthlink.net]
4  activerecord/lib/active_record/associations.rb
@@ -1367,7 +1367,8 @@ def initialize(reflection, join_dependency, parent = nil)
1367 1367
                 table_index = join_dependency.table_aliases[aliased_table_name]
1368 1368
                 @aliased_table_name = @aliased_table_name[0..active_record.connection.table_alias_length-3] + "_#{table_index+1}" if table_index > 0
1369 1369
               end
1370  
-
  1370
+              join_dependency.table_aliases[aliased_table_name] += 1
  1371
+              
1371 1372
               if reflection.macro == :has_and_belongs_to_many || (reflection.macro == :has_many && reflection.options[:through])
1372 1373
                 @aliased_join_table_name = reflection.macro == :has_and_belongs_to_many ? reflection.options[:join_table] : reflection.through_reflection.klass.table_name
1373 1374
                 unless join_dependency.table_aliases[aliased_join_table_name].zero?
@@ -1377,7 +1378,6 @@ def initialize(reflection, join_dependency, parent = nil)
1377 1378
                 end
1378 1379
                 join_dependency.table_aliases[aliased_join_table_name] += 1
1379 1380
               end
1380  
-              join_dependency.table_aliases[aliased_table_name] += 1
1381 1381
             end
1382 1382
 
1383 1383
             def association_join

0 notes on commit ed6c3c1

Please sign in to comment.
Something went wrong with that request. Please try again.