Defect #10176

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

Added by Gonzalo Fernández-Victorio over 6 years ago. Updated 9 months ago.

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


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


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='#{}'" +

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


#1 Updated by Ewan Makepeace over 6 years ago

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

#2 Updated by Toshi MARUYAMA 9 months ago

  • Category set to Custom fields

#3 Updated by Toshi MARUYAMA 9 months ago

  • Description updated (diff)

#4 Updated by Toshi MARUYAMA 9 months ago

  • Status changed from New to Closed

It seems fixed by r12400.

Also available in: Atom PDF