summaryrefslogtreecommitdiffstats
path: root/app/models/custom_field.rb
diff options
context:
space:
mode:
authorEtienne Massip <etienne.massip@gmail.com>2012-06-23 15:47:19 +0000
committerEtienne Massip <etienne.massip@gmail.com>2012-06-23 15:47:19 +0000
commit0cc817fba324c1e66f63d54428b20b318c9ab788 (patch)
treeb5386e335e2cf0e0f891b90ed14e3183686086bd /app/models/custom_field.rb
parent7ed2c481d898ea20db0cec3e9474bf7e43abda21 (diff)
downloadredmine-0cc817fba324c1e66f63d54428b20b318c9ab788.tar.gz
redmine-0cc817fba324c1e66f63d54428b20b318c9ab788.zip
Use base class name as customized type to fix @UserCustomField#order_statement@.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@9880 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/models/custom_field.rb')
-rw-r--r--app/models/custom_field.rb5
1 files changed, 3 insertions, 2 deletions
diff --git a/app/models/custom_field.rb b/app/models/custom_field.rb
index c5c8a9373..24ec67a0f 100644
--- a/app/models/custom_field.rb
+++ b/app/models/custom_field.rb
@@ -139,8 +139,9 @@ class CustomField < ActiveRecord::Base
case field_format
when 'string', 'text', 'list', 'date', 'bool'
# COALESCE is here to make sure that blank and NULL values are sorted equally
+ self.custom_values.first.to_sql
"COALESCE((SELECT cv_sort.value FROM #{CustomValue.table_name} cv_sort" +
- " WHERE cv_sort.customized_type='#{self.class.customized_class.name}'" +
+ " WHERE cv_sort.customized_type='#{self.class.customized_class.base_class.name}'" +
" AND cv_sort.customized_id=#{self.class.customized_class.table_name}.id" +
" AND cv_sort.custom_field_id=#{id} LIMIT 1), '')"
when 'int', 'float'
@@ -148,7 +149,7 @@ class CustomField < ActiveRecord::Base
# Postgresql will raise an error if a value can not be casted!
# CustomValue validations should ensure that it doesn't occur
"(SELECT CAST(cv_sort.value AS decimal(60,3)) FROM #{CustomValue.table_name} cv_sort" +
- " WHERE cv_sort.customized_type='#{self.class.customized_class.name}'" +
+ " WHERE cv_sort.customized_type='#{self.class.customized_class.base_class.name}'" +
" AND cv_sort.customized_id=#{self.class.customized_class.table_name}.id" +
" AND cv_sort.custom_field_id=#{id} AND cv_sort.value <> '' AND cv_sort.value IS NOT NULL LIMIT 1)"
else