Fix JPQL, EQL, and HQL query rendering round-trips#4273
Closed
jewoodev wants to merge 4 commits into
Closed
Conversation
The `TREAT(qualified_identification_variable AS subtype)` alternative of `single_valued_path_expression` was guarded by a condition duplicated from the preceding `qualified_identification_variable` branch, so the branch rendering the downcast was unreachable. `SELECT TREAT(VALUE(m) AS Employee) …` rendered as `SELECT VALUE(m) …`, silently dropping the cast. Check `TREAT()` first so the downcast expression is rendered. Closes spring-projects#4272 Signed-off-by: jewoodev <jewoos15@naver.com>
The optional third argument of `LOCATE` was guarded by `ctx.arithmetic_expression() != null`. As `arithmetic_expression` is a list accessor that never returns `null`, the guard was always true, so `LOCATE('a', e.name)` reached `visit(ctx.arithmetic_expression(0))` with no element and threw a `NullPointerException`.
Check whether the list is empty before rendering the third argument.
Closes spring-projects#4272
Signed-off-by: jewoodev <jewoos15@naver.com>
The subquery `FROM` clause grammar allows a `collection_member_declaration` after the comma (`FROM subselect_identification_variable_declaration (',' (subselect_identification_variable_declaration | collection_member_declaration))*`), but `visitSubquery_from_clause` rendered only `subselect_identification_variable_declaration`. `SELECT l FROM Order o2, IN(o2.lineItems) l …` dropped the `, IN(o2.lineItems) l` term, leaving the alias `l` undefined in the rendered subquery.
Render both declaration types in their source order by iterating over the child nodes.
Closes spring-projects#4272
Signed-off-by: jewoodev <jewoos15@naver.com>
`visitColumnFunction` renders the `columnFunction` rule `column(path '.' jpaNonstandardFunctionName (AS castTarget)?)`, but appended the function name as an expression after the `.` token, and for the optional cast it visited `jpaNonstandardFunctionName()` again instead of `castTarget()`. `column(tbl.foo as int)` rendered as `column(tbl. foo as foo)`, inserting a stray space after the dot and dropping the cast target while repeating the function name. Append the function name without expression spacing and render `castTarget()` after `AS`, as the equivalent `visitJpaNonstandardFunction` already does. Closes spring-projects#4272 Signed-off-by: jewoodev <jewoos15@naver.com>
mp911de
pushed a commit
that referenced
this pull request
Jun 5, 2026
…subqueries. We now render `TREAT(…)` downcasts in qualified identification variables`LOCATE(…)` calls without an offset argument, and collection member declarations in subquery `FROM` clauses correctly. HQL `column(…)` rendering now uses the actual cast target for `column(path as type)`. Closes #4272 Original pull request: #4273 Signed-off-by: jewoodev <jewoos15@naver.com>
mp911de
pushed a commit
that referenced
this pull request
Jun 5, 2026
…subqueries. We now render `TREAT(…)` downcasts in qualified identification variables`LOCATE(…)` calls without an offset argument, and collection member declarations in subquery `FROM` clauses correctly. HQL `column(…)` rendering now uses the actual cast target for `column(path as type)`. Closes #4272 Original pull request: #4273 Signed-off-by: jewoodev <jewoos15@naver.com>
mp911de
pushed a commit
that referenced
this pull request
Jun 5, 2026
…subqueries. We now render `TREAT(…)` downcasts in qualified identification variables`LOCATE(…)` calls without an offset argument, and collection member declarations in subquery `FROM` clauses correctly. HQL `column(…)` rendering now uses the actual cast target for `column(path as type)`. Closes #4272 Original pull request: #4273 Signed-off-by: jewoodev <jewoos15@naver.com>
Member
|
Thank you for your contribution. That's merged, polished, and backported now. |
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
These four focused commits fix renderer-only defects where the JPQL, EQL, and HQL renderers fail to preserve parsed query constructs during rendering. The first three affect
JpqlQueryRendererandEqlQueryRenderer(HQL already round-trips these correctly); the fourth fixes the HQL-onlycolumn(...)function inHqlQueryRenderer. All four are confined to visitor methods, add round-trip tests, and leave the grammars untouched.TREAT(…)downcastTREATbranch guarded by a condition duplicated from the preceding branch → unreachable, cast silently droppedTREAT()firstLOCATE(…)!= nullon a never-null list accessor →visit(null), throwingNullPointerExceptionFROMcollection membervisitSubquery_from_clauserendered only the identification variable, dropping a trailingcollection_member_declarationand leaving its alias undefinedcolumn(…)cast targetvisitColumnFunctionappended the function name as an expression after the.(stray space) and, for the optional cast, visitedjpaNonstandardFunctionName()instead ofcastTarget()→column(tbl.foo as int)rendered ascolumn(tbl. foo as foo)castTarget(), matchingvisitJpaNonstandardFunctionCloses #4272