aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/relation
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2014-05-02 11:52:37 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2014-05-02 11:52:37 -0700
commit3d87c26845095438b6c946dc4e1029280593fb91 (patch)
tree7b342080514fb9d1ff853c4b09f3e874d1cc8a72 /activerecord/lib/active_record/relation
parentdece005f0a8aa1f4210e381efb429eca5d793d91 (diff)
downloadrails-3d87c26845095438b6c946dc4e1029280593fb91.tar.gz
rails-3d87c26845095438b6c946dc4e1029280593fb91.tar.bz2
rails-3d87c26845095438b6c946dc4e1029280593fb91.zip
push up bind params on "simple" subquery calculations
bind parameters we not being propogated to simple subquery calculation calls. This fixes it
Diffstat (limited to 'activerecord/lib/active_record/relation')
-rw-r--r--activerecord/lib/active_record/relation/calculations.rb6
1 files changed, 4 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/relation/calculations.rb b/activerecord/lib/active_record/relation/calculations.rb
index 0b56430b34..42c9881b48 100644
--- a/activerecord/lib/active_record/relation/calculations.rb
+++ b/activerecord/lib/active_record/relation/calculations.rb
@@ -242,7 +242,7 @@ module ActiveRecord
return 0 if relation.limit_value == 0
query_builder = build_count_subquery(relation, column_name, distinct)
- bind_values = relation.bind_values
+ bind_values = query_builder.bind_values + relation.bind_values
else
column = aggregate_column(column_name)
@@ -389,9 +389,11 @@ module ActiveRecord
aliased_column = aggregate_column(column_name == :all ? 1 : column_name).as(column_alias)
relation.select_values = [aliased_column]
- subquery = relation.arel.as(subquery_alias)
+ arel = relation.arel
+ subquery = arel.as(subquery_alias)
sm = Arel::SelectManager.new relation.engine
+ sm.bind_values = arel.bind_values
select_value = operation_over_aggregate_column(column_alias, 'count', distinct)
sm.project(select_value).from(subquery)
end