|
|
@@ -128,7 +128,7 @@ class CustomField < ActiveRecord::Base |
|
|
|
|
|
|
|
# Returns a ORDER BY clause that can used to sort customized |
|
|
|
# objects by their value of the custom field. |
|
|
|
# Returns false, if the custom field can not be used for sorting. |
|
|
|
# Returns nil if the custom field can not be used for sorting. |
|
|
|
def order_statement |
|
|
|
return nil if multiple? |
|
|
|
case field_format |
|
|
@@ -151,6 +151,18 @@ class CustomField < ActiveRecord::Base |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
# Returns a GROUP BY clause that can used to group by custom value |
|
|
|
# Returns nil if the custom field can not be used for grouping. |
|
|
|
def group_statement |
|
|
|
return nil if multiple? |
|
|
|
case field_format |
|
|
|
when 'list', 'date', 'bool', 'int' |
|
|
|
order_statement |
|
|
|
else |
|
|
|
nil |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
def <=>(field) |
|
|
|
position <=> field.position |
|
|
|
end |