mirror of
https://github.com/github/rails.git
synced 2026-04-26 03:00:59 -04:00
refactoring to remove crazy logic
This commit is contained in:
@@ -191,7 +191,11 @@ module ActiveRecord
|
||||
end
|
||||
|
||||
# Postgresql doesn't like ORDER BY when there are no GROUP BY
|
||||
relation = except(:order).select(operation == 'count' ? column.count(distinct) : column.send(operation))
|
||||
relation = except(:order)
|
||||
select_value = operation == 'count' ? column.count(distinct) : column.send(operation)
|
||||
|
||||
relation.select_values = [select_value]
|
||||
|
||||
type_cast_calculated_value(@klass.connection.select_value(relation.to_sql), column_for(column_name), operation)
|
||||
end
|
||||
|
||||
|
||||
@@ -259,14 +259,7 @@ module ActiveRecord
|
||||
def build_select(arel, selects)
|
||||
unless selects.empty?
|
||||
@implicit_readonly = false
|
||||
# TODO: fix this ugly hack, we should refactor the callers to get an Arel compatible array.
|
||||
# Before this change we were passing to Arel the last element only, and Arel is capable of handling an array
|
||||
case select = selects.last
|
||||
when Arel::Expression, Arel::SqlLiteral
|
||||
arel.project(select)
|
||||
else
|
||||
arel.project(*selects)
|
||||
end
|
||||
arel.project(*selects)
|
||||
else
|
||||
arel.project(Arel::SqlLiteral.new(@klass.quoted_table_name + '.*'))
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user