removed requirement to place singleton_value-group_by as the last group_by - added todo for a future refactoring

pull/6827/head
Philipp Tessenow 14 years ago
parent 5eacc58df7
commit 190b8c3118
  1. 8
      app/models/report/group_by/base.rb
  2. 6
      app/models/report/group_by/singleton_value.rb

@ -59,8 +59,12 @@ class Report::GroupBy
def define_group(sql)
fields = all_group_fields
sql.group_by fields
sql.select fields
# fields usually are Strings which we want select and group_by
# sometimes fields are arrays of the form [String,String], where
# the fields.first is to select and where we have to group on field.last
#TODO: differenciate between all_group_fields and all_select_fields
sql.select fields.map {|field| field.is_a?(String) ? field : field.first}
sql.group_by fields.map {|field| field.is_a?(String) ? field : field.last}
end
end
end

@ -2,6 +2,12 @@ class Report::GroupBy
class SingletonValue < Base
dont_display!
def all_group_fields(prefix = true)
parent_fields = parent.all_group_fields if parent
#TODO: differenciate between all_group_fields and all_select_fields
(parent_fields || []) << ['1 as singleton_value', 'singleton_value']
end
def define_group(sql)
sql.select "1 as singleton_value"
sql.group_by "singleton_value"

Loading…
Cancel
Save