aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record
diff options
context:
space:
mode:
authorpinglamb <pinglambs@gmail.com>2015-03-22 16:15:41 +0800
committerpinglamb <pinglambs@gmail.com>2015-03-22 16:25:23 +0800
commitba057a5ebbf93283fc7d3f3f3ffdbae2f8c76fb7 (patch)
tree27ee20c85cfbf85c8bc9b2e9dfc9bd71ee7bca91 /activerecord/lib/active_record
parentfdf55619652fc5200d000241c545323c46bd6b79 (diff)
downloadrails-ba057a5ebbf93283fc7d3f3f3ffdbae2f8c76fb7.tar.gz
rails-ba057a5ebbf93283fc7d3f3f3ffdbae2f8c76fb7.tar.bz2
rails-ba057a5ebbf93283fc7d3f3f3ffdbae2f8c76fb7.zip
Fix referencing wrong aliases while joining tables of has many through
association While joining table of has_many :through association, ActiveRecord will use the actual table name instead of through-join alias. It results with a wrong SQL and exception is raised. This only happens when calculation methods like #count is called. This issue is affecting Rails 4.1.x and 4.2.x as well.
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r--activerecord/lib/active_record/relation/finder_methods.rb2
1 files changed, 1 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/relation/finder_methods.rb b/activerecord/lib/active_record/relation/finder_methods.rb
index 7bd091b66c..3f747a20b3 100644
--- a/activerecord/lib/active_record/relation/finder_methods.rb
+++ b/activerecord/lib/active_record/relation/finder_methods.rb
@@ -378,7 +378,7 @@ module ActiveRecord
def construct_relation_for_association_calculations
from = arel.froms.first
if Arel::Table === from
- apply_join_dependency(self, construct_join_dependency)
+ apply_join_dependency(self, construct_join_dependency(joins_values))
else
# FIXME: as far as I can tell, `from` will always be an Arel::Table.
# There are no tests that test this branch, but presumably it's