jamesfredley opened a new issue, #16717: URL: https://github.com/apache/grails-core/issues/16717
## Summary #16548 added `sqlProjection`. Two shapes of valid SQL fail: a paginated projection whose alias contains a space, and a bracket-quoted identifier that contains an apostrophe. ## What goes wrong `JpaProjectionTranslator` passes the caller's column alias straight to `jpaExpression.alias()`. A paginated query reuses that selection in a derived subquery. An alias such as `box width` is rendered unquoted as `derived1_0(box width)`, which is invalid SQL, and `totalCount` fails. The alias used for DSL lookup can stay as the caller wrote it. The alias used inside the subquery has to be generated or quoted. `SqlProjection.splitColumns()` treats `'`, `"`, and `` ` `` as string delimiters before it looks at square brackets. A projection such as `width as [box's width], height as total` therefore sees the apostrophe as the start of a string, consumes the rest of the SQL, and is rejected as one column instead of two. Bracket-quoted identifiers have to be recognized before embedded quotes. ## Introduced by - https://github.com/apache/grails-core/pull/16548 - Merge commit `0e8fd03e56c2574e87ac824cd7831221e803873d` on `8.0.x` - `JpaProjectionTranslator.java` lines 112-114 - `SqlProjection.java` lines 168-173 ## Fix Quote or replace aliases before they are reused in a count subquery, and scan bracket-quoted identifiers before string literals. Add regressions for `sqlProjection` with alias `box width` plus `totalCount`, and for `width as [box's width], height as total`. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
