Defect #10176

Custom fields of type "User" can't be ordered

Added by Gonzalo Fernández-Victorio almost 6 years ago. Updated 3 months ago.

Status:ClosedStart date:
Priority:NormalDue date:
Assignee:-% Done:

0%

Category:Custom fields
Target version:-
Resolution: Affected version:1.3.0

Description

I cannot order a query by a custom Field of type Users of of type Version.

This defect is similar to #9920. However, that one had two issues ("order_by in a project" and "query in all projects") and was closed as a duplicated of #9445. I understand that "query in all projects" is a duplicate of #9445 but "order_by in a project" keeps unresolved.

I have managed to resolve for our own installation with the following modification (needs proper test and testing for being a patch)

--- custom_field.rb    (Redmine Bitnami 1.3.0)
+++ custom_field.rb    (working copy)
@@ -122,7 +122,7 @@
   # Returns false, if the custom field can not be used for sorting.
   def order_statement
     case field_format
-      when 'string', 'text', 'list', 'date', 'bool'
+      when 'string', 'text', 'list', 'date', 'bool', 'user', 'version'
         # COALESCE is here to make sure that blank and NULL values are sorted equally
         "COALESCE((SELECT cv_sort.value FROM #{CustomValue.table_name} cv_sort" +
           " WHERE cv_sort.customized_type='#{self.class.customized_class.name}'" +


Related issues

Related to Redmine - Feature #9445: Add Issue custom fields of User-format to the cross-proje... Closed 2011-10-21
Related to Redmine - Defect #9920: Custom fields of type "User" can't be ordered and used in... Closed

History

#1 Updated by Ewan Makepeace almost 6 years ago

Related: I dont need to sort but want to "Group By" my custom User field...

#2 Updated by Toshi MARUYAMA 3 months ago

  • Category set to Custom fields

#3 Updated by Toshi MARUYAMA 3 months ago

  • Description updated (diff)

#4 Updated by Toshi MARUYAMA 3 months ago

  • Status changed from New to Closed

It seems fixed by r12400.

Also available in: Atom PDF