Skip to content

Commit

Permalink
ensure group_by_join_statement is nil when group_by_statement is nil
Browse files Browse the repository at this point in the history
  • Loading branch information
toy committed Oct 10, 2024
1 parent 17c8725 commit 73daf9f
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion app/models/custom_field/order_statements.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,19 +67,23 @@ def order_null_handling(asc)
# which differ for multi-value select fields,
# because in this case we do want the primary CV values
def group_by_statement
return unless field_format.in?(%w[list date bool int float string link])
return unless can_be_used_for_grouping?

order_statement
end

def group_by_join_statement
return unless can_be_used_for_grouping?

return join_for_group_by_list_sql if field_format == "list"

order_join_statement
end

private

def can_be_used_for_grouping? = field_format.in?(%w[list date bool int float string link])

def join_for_order_sql(value:, join: nil, multi_value: false)
<<-SQL.squish
LEFT OUTER JOIN (
Expand Down

0 comments on commit 73daf9f

Please sign in to comment.