Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

fix grouping by cf while summing (#8881)

ulfertsbf9bc70bb18d
diff --git a/app/models/custom_field/order_statements.rb b/app/models/custom_field/order_statements.rb
index 24694a267a5..82cae3e1e04 100644
--- a/app/models/custom_field/order_statements.rb
+++ b/app/models/custom_field/order_statements.rb
@@ -43,7 +43,7 @@ module CustomField::OrderStatements
if multi_value?
[select_custom_values_as_group]
else
- coalesce_select_custom_value_as_string
+ [coalesce_select_custom_value_as_string]
end
when 'int', 'float'
# Make the database cast values into numeric
@@ -73,12 +73,12 @@ module CustomField::OrderStatements
# Returns the grouping result
# which differ for multi-value select fields,
# because in this case we do want the primary CV values
- def group_by_statements
+ def group_by_statement
return order_statements unless field_format == 'list'
if multi_value?
# We want to return the internal IDs in the case of grouping
- [select_custom_values_as_group]
+ select_custom_values_as_group
else
coalesce_select_custom_value_as_string
end
@@ -88,11 +88,9 @@ module CustomField::OrderStatements
def coalesce_select_custom_value_as_string
# COALESCE is here to make sure that blank and NULL values are sorted equally
- [
- <<-SQL
- COALESCE(#{select_custom_value_as_string}, '')
- SQL
- ]
+ <<-SQL
+ COALESCE(#{select_custom_value_as_string}, '')
+ SQL
end
def select_custom_value_as_string
diff --git a/app/models/queries/work_packages/columns/custom_field_column.rb b/app/models/queries/work_packages/columns/custom_field_column.rb
index 3f0ac753e48..24676fca2bf 100644
--- a/app/models/queries/work_packages/columns/custom_field_column.rb
+++ b/app/models/queries/work_packages/columns/custom_field_column.rb
@@ -81,7 +81,7 @@ class Queries::WorkPackages::Columns::CustomFieldColumn < Queries::WorkPackages:
end
def set_groupable!
- self.groupable = custom_field.group_by_statements if groupable_custom_field?(custom_field)
+ self.groupable = custom_field.group_by_statement if groupable_custom_field?(custom_field)
self.groupable ||= false
end