Fix JPQL, EQL, and HQL query rendering round-trips by jewoodev · Pull Request #4273 · spring-projects/spring-data-jpa (original) (raw)
added 3 commits
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
jewoodev changed the title
Fix JPQL and EQL renderer round-trip for TREAT, LOCATE, and subquery FROM Fix JPQL, EQL, and HQL query rendering round-trips
mp911de pushed a commit that referenced this pull request
…subqueries.
We now render TREAT(…) downcasts in qualified identification variablesLOCATE(…) 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 added a commit that referenced this pull request
Remove unused code, add missing annotation.
See #4272 Original pull request: #4273
mp911de pushed a commit that referenced this pull request
…subqueries.
We now render TREAT(…) downcasts in qualified identification variablesLOCATE(…) 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 added a commit that referenced this pull request
Properly support DISTINCT queries without a primary alias. Remove unused code, add missing annotation.
See #4272 Original pull request: #4273
mp911de pushed a commit that referenced this pull request
…subqueries.
We now render TREAT(…) downcasts in qualified identification variablesLOCATE(…) 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 added a commit that referenced this pull request
Properly support DISTINCT queries without a primary alias. Remove unused code, add missing annotation.
See #4272 Original pull request: #4273
jewoodev deleted the jpql-eql-renderer-spec-fixes branch
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
[ Show hidden characters]({{ revealButtonHref }})