borinquenkid opened a new issue, #16616:
URL: https://github.com/apache/grails-core/issues/16616
## Summary
`HqlQueryContext` (GORM for Hibernate 7) is a `record` that also holds the
HQL scanner, the query rewriting and the parameter handling. Split it into
small classes once the Groovy conversion of the module has landed.
## Why
PR #16597 fixes HQL queries with a subquery being rewritten into invalid
HQL. The defect came from a text scanner living next to parameter handling:
`indexOf("select ")` and `indexOf(" from ")` were repeated in four methods,
each with its own idea of where the query itself starts. #16597 puts the search
in two helpers, but they are still `private static` methods of the same record,
and every method still lowercases and rescans the string.
## Proposal
* `HqlText` (or `HqlStatement`): the HQL string and everything that reads
it: the top-level `select`/`from` search (outside parentheses, string literals,
quoted identifiers and comments), `normalizeNonAliasedSelect`, `getRootAlias`,
`countHqlProjections`, `getSingleProjectionClause` and the result type. The
positions are found once.
* `QueryParameters`: the named and positional parameters, the expansion of a
`GString`, and `convertValue`.
* `QuerySettings`: the settings map and the hints, with the `AvailableHints`
filter inside the class.
* `HqlQueryContext`: a thin record of the three, the target class and the
`isUpdate`/`isNative` flags.
No change of behavior. `HqlQueryContextSpec` and
`HibernateGormStaticApiSpec` stay as they are and are the safety net; add small
specs for `HqlText` and `QueryParameters`, including a leading `with` clause,
names that contain `select`, and escaped quotes.
## Order
1. #16597 lands on 8.0.x.
2. #16572 converts the module to Groovy.
3. This refactor, on 9.0.x, as its own pull request, so that it is not read
as part of a mechanical language conversion.
--
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]