You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by tu...@apache.org on 2023/12/19 02:23:37 UTC
(shardingsphere) branch master updated: Fix sqlServer unqualified shorthand parsing (#29354)
This is an automated email from the ASF dual-hosted git repository.
tuichenchuxin pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git
The following commit(s) were added to refs/heads/master by this push:
new 67b7a068332 Fix sqlServer unqualified shorthand parsing (#29354)
67b7a068332 is described below
commit 67b7a068332038f12f2eca4bddf7566a48f7c2ec
Author: ZhangCheng <ch...@apache.org>
AuthorDate: Tue Dec 19 10:23:30 2023 +0800
Fix sqlServer unqualified shorthand parsing (#29354)
---
.../sqlserver/src/main/antlr4/imports/sqlserver/DMLStatement.g4 | 2 +-
.../sqlserver/visitor/statement/SQLServerStatementVisitor.java | 5 +++--
2 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/parser/sql/dialect/sqlserver/src/main/antlr4/imports/sqlserver/DMLStatement.g4 b/parser/sql/dialect/sqlserver/src/main/antlr4/imports/sqlserver/DMLStatement.g4
index e868949cba9..05e32f0c2c9 100644
--- a/parser/sql/dialect/sqlserver/src/main/antlr4/imports/sqlserver/DMLStatement.g4
+++ b/parser/sql/dialect/sqlserver/src/main/antlr4/imports/sqlserver/DMLStatement.g4
@@ -89,7 +89,7 @@ duplicateSpecification
;
projections
- : (unqualifiedShorthand | projection) (COMMA_ projection)*
+ : (unqualifiedShorthand | projection) (COMMA_ (unqualifiedShorthand | projection))*
;
projection
diff --git a/parser/sql/dialect/sqlserver/src/main/java/org/apache/shardingsphere/sql/parser/sqlserver/visitor/statement/SQLServerStatementVisitor.java b/parser/sql/dialect/sqlserver/src/main/java/org/apache/shardingsphere/sql/parser/sqlserver/visitor/statement/SQLServerStatementVisitor.java
index af86cd13b07..0e50e554efe 100644
--- a/parser/sql/dialect/sqlserver/src/main/java/org/apache/shardingsphere/sql/parser/sqlserver/visitor/statement/SQLServerStatementVisitor.java
+++ b/parser/sql/dialect/sqlserver/src/main/java/org/apache/shardingsphere/sql/parser/sqlserver/visitor/statement/SQLServerStatementVisitor.java
@@ -102,6 +102,7 @@ import org.apache.shardingsphere.sql.parser.autogen.SQLServerStatementParser.Tab
import org.apache.shardingsphere.sql.parser.autogen.SQLServerStatementParser.TableReferenceContext;
import org.apache.shardingsphere.sql.parser.autogen.SQLServerStatementParser.TableReferencesContext;
import org.apache.shardingsphere.sql.parser.autogen.SQLServerStatementParser.TopContext;
+import org.apache.shardingsphere.sql.parser.autogen.SQLServerStatementParser.UnqualifiedShorthandContext;
import org.apache.shardingsphere.sql.parser.autogen.SQLServerStatementParser.UnreservedWordContext;
import org.apache.shardingsphere.sql.parser.autogen.SQLServerStatementParser.UpdateContext;
import org.apache.shardingsphere.sql.parser.autogen.SQLServerStatementParser.ViewNameContext;
@@ -850,8 +851,8 @@ public abstract class SQLServerStatementVisitor extends SQLServerStatementBaseVi
@Override
public ASTNode visitProjections(final ProjectionsContext ctx) {
Collection<ProjectionSegment> projections = new LinkedList<>();
- if (null != ctx.unqualifiedShorthand()) {
- projections.add(new ShorthandProjectionSegment(ctx.unqualifiedShorthand().getStart().getStartIndex(), ctx.unqualifiedShorthand().getStop().getStopIndex()));
+ for (UnqualifiedShorthandContext each : ctx.unqualifiedShorthand()) {
+ projections.add(new ShorthandProjectionSegment(each.getStart().getStartIndex(), each.getStop().getStopIndex()));
}
for (ProjectionContext each : ctx.projection()) {
projections.add((ProjectionSegment) visit(each));