Project

General

Profile

Defect #10176

Updated by Toshi MARUYAMA over 6 years ago

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) 
 <pre><code class="diff"> <pre> 
 --- 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}'" + 
 </code></pre> </pre> 




Back