diff --git a/app/models/custom_field.rb b/app/models/custom_field.rb index 24ec67a..5d528cd 100644 --- a/app/models/custom_field.rb +++ b/app/models/custom_field.rb @@ -139,7 +139,6 @@ 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.base_class.name}'" + " AND cv_sort.customized_id=#{self.class.customized_class.table_name}.id" +