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
rename order_statements to order_statement swithcing it to return single statement
Ivan Kuchin86ab142d89c5
diff --git a/app/models/custom_field/order_statements.rb b/app/models/custom_field/order_statements.rbindex 98c46c8c816..79b773ec7db 100644--- a/app/models/custom_field/order_statements.rb+++ b/app/models/custom_field/order_statements.rb@@ -30,21 +30,21 @@ module CustomField::OrderStatements# Returns a ORDER BY clause that can used to sort customized# objects by their value of the custom field.# Returns false, if the custom field can not be used for sorting.- def order_statements+ def order_statementcase field_formatwhen "list"- [order_by_list_sql]+ order_by_list_sqlwhen "string", "date", "bool", "link"- [coalesce_select_custom_value_as_string]+ coalesce_select_custom_value_as_stringwhen "int", "float"# Make the database cast values into numeric# Postgresql will raise an error if a value can not be casted!# CustomValue validations should ensure that it doesn't occur- [select_custom_value_as_decimal]+ select_custom_value_as_decimalwhen "user"- [order_by_user_sql]+ order_by_user_sqlwhen "version"- [order_by_version_sql]+ order_by_version_sqlendend@@ -61,7 +61,7 @@ module CustomField::OrderStatements# which differ for multi-value select fields,# because in this case we do want the primary CV valuesdef group_by_statement- return order_statements unless field_format == "list"+ return order_statement unless field_format == "list"if multi_value?# We want to return the internal IDs in the case of groupingdiff --git a/app/models/queries/projects/orders/custom_field_order.rb b/app/models/queries/projects/orders/custom_field_order.rbindex 30aa9e3b455..d9ca8de9d1c 100644--- a/app/models/queries/projects/orders/custom_field_order.rb+++ b/app/models/queries/projects/orders/custom_field_order.rb@@ -58,9 +58,7 @@ class Queries::Projects::Orders::CustomFieldOrder < Queries::Orders::Baseprivatedef order(scope)- joined_statement = custom_field.order_statements.map do |statement|- Arel.sql("#{statement} #{direction}")- end+ joined_statement = Arel.sql("#{custom_field.order_statement} #{direction}")scope.order(joined_statement)enddiff --git a/app/models/queries/work_packages/selects/custom_field_select.rb b/app/models/queries/work_packages/selects/custom_field_select.rbindex 38e429839ad..e4b09ad81b9 100644--- a/app/models/queries/work_packages/selects/custom_field_select.rb+++ b/app/models/queries/work_packages/selects/custom_field_select.rb@@ -33,7 +33,7 @@ class Queries::WorkPackages::Selects::CustomFieldSelect < Queries::WorkPackages:@cf = custom_field@name = custom_field.column_name.to_sym- @sortable = custom_field.order_statements || false+ @sortable = custom_field.order_statement || false@groupable = groupable_custom_field?(custom_field) ? custom_field.group_by_statement || false : false@summable = summable_statementenddiff --git a/app/models/query/results.rb b/app/models/query/results.rbindex dbf58dcbfa8..51a09954580 100644--- a/app/models/query/results.rb+++ b/app/models/query/results.rb@@ -195,10 +195,8 @@ class Query::Results### Return the case insensitive version for columns with a string typedef case_insensitive_condition(column_key, condition, columns_hash)- if columns_hash[column_key]&.type == :string+ if columns_hash[column_key]&.type == :string || custom_field_type(column_key) == "string""LOWER(#{condition})"- elsif custom_field_type(column_key) == "string"- condition.map { |c| "LOWER(#{c})" }elseconditionend