aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/relation
diff options
context:
space:
mode:
authorJon Leighton <j@jonathanleighton.com>2011-08-29 15:01:17 +0100
committerJon Leighton <j@jonathanleighton.com>2011-08-29 15:05:47 +0100
commit735d985b0162976e7e900cf36d4cbb0d657fb5e9 (patch)
tree6d28ea963504b2f458b81eb6c32ac471b937f316 /activerecord/lib/active_record/relation
parentfd22d040fef48778a519825dd2f0cf2fd73a8965 (diff)
downloadrails-735d985b0162976e7e900cf36d4cbb0d657fb5e9.tar.gz
rails-735d985b0162976e7e900cf36d4cbb0d657fb5e9.tar.bz2
rails-735d985b0162976e7e900cf36d4cbb0d657fb5e9.zip
The join_nodes must be passed to the JoinDependency initializer and therefore counted by the alias tracker. This is because the association_joins are aliased on initialization and then the tables are cached, so it is no use to alias the join_nodes later. Fixes #2556.
Diffstat (limited to 'activerecord/lib/active_record/relation')
-rw-r--r--activerecord/lib/active_record/relation/query_methods.rb9
1 files changed, 2 insertions, 7 deletions
diff --git a/activerecord/lib/active_record/relation/query_methods.rb b/activerecord/lib/active_record/relation/query_methods.rb
index 1654ae1eac..7eda9ad8e8 100644
--- a/activerecord/lib/active_record/relation/query_methods.rb
+++ b/activerecord/lib/active_record/relation/query_methods.rb
@@ -254,12 +254,12 @@ module ActiveRecord
association_joins = buckets['association_join'] || []
stashed_association_joins = buckets['stashed_join'] || []
- join_nodes = buckets['join_node'] || []
+ join_nodes = (buckets['join_node'] || []).uniq
string_joins = (buckets['string_join'] || []).map { |x|
x.strip
}.uniq
- join_list = custom_join_ast(manager, string_joins)
+ join_list = join_nodes + custom_join_ast(manager, string_joins)
join_dependency = ActiveRecord::Associations::JoinDependency.new(
@klass,
@@ -267,10 +267,6 @@ module ActiveRecord
join_list
)
- join_nodes.each do |join|
- join_dependency.alias_tracker.aliased_name_for(join.left.name.downcase)
- end
-
join_dependency.graft(*stashed_association_joins)
@implicit_readonly = true unless association_joins.empty? && stashed_association_joins.empty?
@@ -280,7 +276,6 @@ module ActiveRecord
association.join_to(manager)
end
- manager.join_sources.concat join_nodes.uniq
manager.join_sources.concat join_list
manager