You have to define custom_finder_options and add group options when
active_scaffold_config.list.user.sorting.sorts_on? :findings
def custom_finder_options
if active_scaffold_config.list.user.sorting.sorts_on? :findings
{group: 'tbl_node.node_id'}
else
{}
end
end
El lunes, 5 de marzo de 2018 15:30:55 (CET) Jan Hebler escribió:
> Hi
>
> I want to sort by an calculation on an associated table, i.E.
>
>
> config.columns[:findings].includes = [ :vulnerabilities ]
> config.columns[:findings].sort_by :sql => 'sum(vulnerabilities.score)'
>
>
> This doesn't work as AS don't set the necessary "group by"-clause:
>
> ActionView::Template::Error (PG::GroupingError: ERROR: column
> "tbl_node.node_id" must appear in the GROUP BY clause or be used in an
> aggregate function
> LINE 1: SELECT DISTINCT "tbl_node"."node_id", sum(vulnerabilities.s...
> ^
>
> : SELECT DISTINCT "tbl_node"."node_id", sum(vulnerabilities.score) AS
>
> alias_0, "tbl_node"."node_id" AS alias_1 FROM "tbl_node" LEFT OUTER JOIN
> "findings" ON "findings"."system_id" = "tbl_node"."node_id" AND
> (findingstate_id != 4) LEFT OUTER JOIN "vulnerabilities" ON
> "vulnerabilities"."id" = "findings"."vulnerability_id" WHERE ('t'='t')
> ORDER BY sum(vulnerabilities.score) ASC, "tbl_node"."node_id" ASC LIMIT $1
> OFFSET $2):
>
>
> Is there any possibility to tell AS to set this clause?
>
> Thanks, Jan
--
You received this message because you are subscribed to the Google Groups
"ActiveScaffold : Ruby on Rails Gem" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/activescaffold.
For more options, visit https://groups.google.com/d/optout.