Skip to content

Commit 1121b30

Browse files
authored
fix quote parsing in columns (#6471)
* add dbtype adb_mysql * Presto/Trino parser fix * add CTE visit for insertNode * add keyword config for spark/hive * support synapse parser * support synapse parser * lexer fix: comment character missing * lexer fix: comment character missing * fix quote parsing in columns
1 parent a67023f commit 1121b30

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

core/src/main/java/com/alibaba/druid/sql/visitor/SQLASTOutputVisitor.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1569,7 +1569,12 @@ public boolean visit(SQLIdentifierExpr x) {
15691569
if (x.isParenthesized()) {
15701570
print('(');
15711571
}
1572-
printName0(x.getName());
1572+
String replacedName = x.getName();
1573+
if (x.getParent() instanceof SQLBinaryOpExpr
1574+
|| x.getParent() instanceof SQLSelectItem) {
1575+
replacedName = replaceQuota(x.getName());
1576+
}
1577+
printName0(replacedName);
15731578
if (x.getCollate() != null) {
15741579
String collate = x.getCollate();
15751580
print(" COLLATE ");

core/src/test/resources/bvt/parser/sqlserver/0.txt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,22 @@ select * from [test].[test]
1212
SELECT *
1313
FROM [test].[test]
1414
------------------------------------------------------------------------------------------------------------------------
15+
CREATE VIEW [a].[b]
16+
AS SELECT
17+
*
18+
, [c] = DATEDIFF(MILLISECOND, request_time, GETDATE()) / 1000.0
19+
FROM
20+
tbl
21+
WHERE
22+
[state] = 'Queued';
23+
--------------------
24+
CREATE VIEW [a].[b]
25+
AS
26+
SELECT *
27+
, [c] = DATEDIFF(MILLISECOND, request_time, GETDATE()) / 1000.0
28+
FROM tbl
29+
WHERE [state] = 'Queued';
30+
------------------------------------------------------------------------------------------------------------------------
1531
USE AdventureWorks2008R2
1632
--------------------
1733
USE AdventureWorks2008R2

0 commit comments

Comments
 (0)