Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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 technoweenie authored
2  activerecord/CHANGELOG
View
@@ -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]
4 activerecord/lib/active_record/associations.rb
View
@@ -1367,7 +1367,8 @@ def initialize(reflection, join_dependency, parent = nil)
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 @@ def initialize(reflection, join_dependency, parent = nil)
end
join_dependency.table_aliases[aliased_join_table_name] += 1
end
- join_dependency.table_aliases[aliased_table_name] += 1
end
def association_join
Please sign in to comment.
Something went wrong with that request. Please try again.