Skip to content

Data Services: Fix @Where aggregate subquery translation generating invalid SQL #16807

Open

Description

@borinquenkid

Split from monolithic audit #16674 (finding F21).

Problem Description

In GORM Data Services, using an aggregate expression inside @Where:

@Where({ amount > avg(amount) })

generates invalid SQL because the aggregate projection (avg(amount)) is applied directly to the outer WHERE clause instead of being encapsulated in a subquery (WHERE amount > (SELECT avg(amount) FROM ...)).

Expected Behavior

The AST transformation for @Where should properly emit a subquery expression when an aggregate function is referenced on the right-hand side of a comparison operator.

Activity

  1. added this to the grails:9.0.0-M1 milestone on Oct 31, 2026
  2. borinquenkid commented on Oct 31, 2026

    @borinquenkid
    MemberAuthor

    Targeted for Grails 9.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions