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

allow using index scan on sorting by list cf

ulferts2b126dd06417
diff --git a/app/models/custom_field/order_statements.rb b/app/models/custom_field/order_statements.rb
index 569a47badf3..628bf1f93f3 100644
--- a/app/models/custom_field/order_statements.rb
+++ b/app/models/custom_field/order_statements.rb
@@ -109,8 +109,9 @@ module CustomField::OrderStatements
(SELECT co_sort.position FROM #{CustomOption.table_name} co_sort
LEFT JOIN #{CustomValue.table_name} cv_sort
ON co_sort.id = CAST(cv_sort.value AS decimal(60,3))
- WHERE cv_sort.custom_field_id=#{id}
+ WHERE cv_sort.customized_type='#{self.class.customized_class.name}'
AND cv_sort.customized_id=#{self.class.customized_class.table_name}.id
+ AND cv_sort.custom_field_id=#{id}
LIMIT 1
)
SQL