Project

General

Profile

Actions

Defect #11073

closed

UserCustomField order_statement returns wrong output

Added by Devadatta Sahoo almost 12 years ago. Updated almost 12 years ago.

Status:
Closed
Priority:
Normal
Category:
Custom fields
Target version:
Start date:
Due date:
% Done:

0%

Estimated time:
Resolution:
Fixed
Affected version:

Description

The UserCustomField order_statement returns wrong output:

Eg:
For a user custom field named "Employee Code" (type string) the order statement is returned as follows:

>> UserCustomField.find_by_name("Employee Code").order_statement
=> "COALESCE((SELECT cv_sort.value FROM custom_values cv_sort WHERE cv_sort.customized_type='User' AND cv_sort.customized_id=users.id AND cv_sort.custom_field_id=1 LIMIT 1), '')"

Herein the value of customized_type is User, whereas in the actual database table, i.e. custom_values table, the value of customized_type for UserCustomFields is Principal (which is a superclass of User class).

For this reason, the `UserCustomField.find_by_name("Employee Code").order_statement` gives a statement which always returns empty output when used in a query.

The correct value of `UserCustomField.find_by_name("Employee Code").order_statement` should be:

>> UserCustomField.find_by_name("Employee Code").order_statement
=> "COALESCE((SELECT cv_sort.value FROM custom_values cv_sort WHERE cv_sort.customized_type='Principal' AND cv_sort.customized_id=users.id AND cv_sort.custom_field_id=1 LIMIT 1), '')"


Files

custom_field.rb.patch (1.64 KB) custom_field.rb.patch Devadatta Sahoo, 2012-06-01 20:06

Related issues

Related to Redmine - Feature #1139: Being able to sort the issue list by custom fieldsClosedJean-Philippe Lang2008-04-29

Actions
Actions

Also available in: Atom PDF