mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
re-introduce select_for_count
private method.
See da9b5d4a84 (commitcomment-3630064)
for discussion.
This commit is contained in:
parent
b5e851e90b
commit
648afea0e4
1 changed files with 10 additions and 5 deletions
|
@ -189,11 +189,7 @@ module ActiveRecord
|
|||
distinct = self.distinct_value
|
||||
|
||||
if operation == "count"
|
||||
if select_values.present?
|
||||
column_name ||= select_values.join(", ")
|
||||
else
|
||||
column_name ||= :all
|
||||
end
|
||||
column_name ||= select_for_count
|
||||
|
||||
unless arel.ast.grep(Arel::Nodes::OuterJoin).empty?
|
||||
distinct = true
|
||||
|
@ -361,6 +357,15 @@ module ActiveRecord
|
|||
column ? column.type_cast(value) : value
|
||||
end
|
||||
|
||||
# TODO: refactor to allow non-string `select_values` (eg. Arel nodes).
|
||||
def select_for_count
|
||||
if select_values.present?
|
||||
select_values.join(", ")
|
||||
else
|
||||
:all
|
||||
end
|
||||
end
|
||||
|
||||
def build_count_subquery(relation, column_name, distinct)
|
||||
column_alias = Arel.sql('count_column')
|
||||
subquery_alias = Arel.sql('subquery_for_count')
|
||||
|
|
Loading…
Reference in a new issue