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
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
fix join statement for group by to return ids instead of positions
Ivan Kuchin70b1acbadcbd
diff --git a/app/models/custom_field/order_statements.rb b/app/models/custom_field/order_statements.rbindex 25401cb60cb..b1f22c94534 100644--- a/app/models/custom_field/order_statements.rb+++ b/app/models/custom_field/order_statements.rb@@ -75,6 +75,8 @@ module CustomField::OrderStatements# Returns the join statement that is required to group objects by their value# of the custom field.def group_by_join_statement+ return join_for_group_by_list_sql if field_format == "list"+order_join_statementend@@ -159,6 +161,38 @@ module CustomField::OrderStatementsendend+ def join_for_group_by_list_sql+ if multi_value?+ <<-SQL.squish+ LEFT OUTER JOIN (+ SELECT cv.customized_id, array_to_string(array_agg(cv.value ORDER BY co.position), '.') "value"+ FROM #{CustomValue.quoted_table_name} cv+ INNER JOIN #{CustomOption.quoted_table_name} co+ ON co.id = cv.value::bigint+ WHERE cv.customized_type = #{CustomValue.connection.quote(self.class.customized_class.name)}+ AND cv.custom_field_id = #{id}+ AND cv.value IS NOT NULL+ AND cv.value != ''+ GROUP BY cv.customized_id+ ) cf_order_#{id}+ ON cf_order_#{id}.customized_id = #{self.class.customized_class.quoted_table_name}.id+ SQL+ else+ <<-SQL.squish+ LEFT OUTER JOIN (+ SELECT DISTINCT ON (cv.customized_id) cv.customized_id, cv.value "value"+ FROM #{CustomValue.quoted_table_name} cv+ WHERE cv.customized_type = #{CustomValue.connection.quote(self.class.customized_class.name)}+ AND cv.custom_field_id = #{id}+ AND cv.value IS NOT NULL+ AND cv.value != ''+ ORDER BY cv.customized_id, cv.id+ ) cf_order_#{id}+ ON cf_order_#{id}.customized_id = #{self.class.customized_class.quoted_table_name}.id+ SQL+ end+ end+def join_for_order_by_user_sqlcolumns_array = "ARRAY[users.lastname, users.firstname, users.mail]"