Polishing.

Refine JOIN and function keyword rendering.

See #3692
This commit is contained in:
Mark Paluch
2025-01-09 11:37:41 +01:00
parent 2e58485e06
commit 19571e4386
3 changed files with 12 additions and 9 deletions

View File

@@ -168,6 +168,7 @@ class HqlCountQueryTransformer extends HqlQueryRenderer {
QueryRendererBuilder builder = QueryRenderer.builder();
builder.append(TOKEN_SPACE);
builder.appendExpression(visit(ctx.joinType()));
builder.append(QueryTokens.expression(ctx.JOIN()));

View File

@@ -329,8 +329,8 @@ class HqlQueryRenderer extends HqlBaseVisitor<QueryTokenStream> {
QueryRendererBuilder builder = QueryRenderer.builder();
builder.appendExpression(visit(ctx.fromRoot()));
builder.appendInline(QueryTokenStream.concat(ctx.joinSpecifier(), this::visit, TOKEN_SPACE));
builder.appendInline(visit(ctx.fromRoot()));
builder.appendInline(QueryTokenStream.concat(ctx.joinSpecifier(), this::visit, EMPTY_TOKEN));
return builder;
}
@@ -389,6 +389,7 @@ class HqlQueryRenderer extends HqlBaseVisitor<QueryTokenStream> {
QueryRendererBuilder builder = QueryRenderer.builder();
builder.append(TOKEN_SPACE);
builder.append(visit(ctx.joinType()));
builder.append(QueryTokens.expression(ctx.JOIN()));
@@ -746,7 +747,7 @@ class HqlQueryRenderer extends HqlBaseVisitor<QueryTokenStream> {
QueryRendererBuilder builder = QueryRenderer.builder();
builder.append(QueryTokens.expression(ctx.OFFSET()));
builder.append(visit(ctx.parameterOrIntegerLiteral()));
builder.appendExpression(visit(ctx.parameterOrIntegerLiteral()));
if (ctx.ROW() != null) {
builder.append(QueryTokens.expression(ctx.ROW()));
@@ -3377,7 +3378,7 @@ class HqlQueryRenderer extends HqlBaseVisitor<QueryTokenStream> {
builder.append(TOKEN_CLOSE_PAREN);
} else {
builder.appendExpression(visit(ctx.collectionQuantifier()));
builder.append(visit(ctx.collectionQuantifier()));
builder.append(TOKEN_OPEN_PAREN);
builder.appendInline(visit(ctx.simplePath()));
@@ -3412,7 +3413,7 @@ class HqlQueryRenderer extends HqlBaseVisitor<QueryTokenStream> {
builder.append(TOKEN_CLOSE_PAREN);
} else {
builder.appendExpression(visit(ctx.collectionQuantifier()));
builder.append(visit(ctx.collectionQuantifier()));
builder.append(TOKEN_OPEN_PAREN);
builder.appendInline(visit(ctx.simplePath()));
@@ -3801,9 +3802,9 @@ class HqlQueryRenderer extends HqlBaseVisitor<QueryTokenStream> {
if (ctx.simplePath() != null) {
if (ctx.ELEMENTS() != null) {
builder.append(QueryTokens.expression(ctx.ELEMENTS()));
builder.append(QueryTokens.token(ctx.ELEMENTS()));
} else if (ctx.INDICES() != null) {
builder.append(QueryTokens.expression(ctx.INDICES()));
builder.append(QueryTokens.token(ctx.INDICES()));
}
builder.append(TOKEN_OPEN_PAREN);
@@ -3836,9 +3837,9 @@ class HqlQueryRenderer extends HqlBaseVisitor<QueryTokenStream> {
builder.append(QueryTokens.expression(ctx.EXISTS()));
if (ctx.ELEMENTS() != null) {
builder.append(QueryTokens.expression(ctx.ELEMENTS()));
builder.append(QueryTokens.token(ctx.ELEMENTS()));
} else if (ctx.INDICES() != null) {
builder.append(QueryTokens.expression(ctx.INDICES()));
builder.append(QueryTokens.token(ctx.INDICES()));
}
builder.append(TOKEN_OPEN_PAREN);

View File

@@ -31,6 +31,7 @@ class QueryTokens {
/**
* Commonly use tokens.
*/
static final QueryToken EMPTY_TOKEN = token("");
static final QueryToken TOKEN_COMMA = token(", ");
static final QueryToken TOKEN_SPACE = token(" ");
static final QueryToken TOKEN_DOT = token(".");