mirror of
https://github.com/tencentmusic/supersonic.git
synced 2025-12-18 08:17:18 +00:00
(improvement)(Headless) remove mysql function name backticks (#909)
This commit is contained in:
@@ -89,12 +89,7 @@ public abstract class SemanticNode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static String getSql(SqlNode sqlNode, EngineType engineType) {
|
public static String getSql(SqlNode sqlNode, EngineType engineType) {
|
||||||
SemanticSqlDialect sqlDialect = SqlDialectFactory.getSqlDialect(engineType);
|
UnaryOperator<SqlWriterConfig> sqlWriterConfigUnaryOperator = (c) -> getSqlWriterConfig(engineType);
|
||||||
SqlWriterConfig config = SqlPrettyWriter.config().withDialect(sqlDialect)
|
|
||||||
.withKeywordsLowerCase(false).withClauseEndsLine(true).withAlwaysUseParentheses(false)
|
|
||||||
.withSelectListItemsOnSeparateLines(false).withUpdateSetListNewline(false).withIndentation(0);
|
|
||||||
|
|
||||||
UnaryOperator<SqlWriterConfig> sqlWriterConfigUnaryOperator = (c) -> config;
|
|
||||||
return sqlNode.toSqlString(sqlWriterConfigUnaryOperator).getSql();
|
return sqlNode.toSqlString(sqlWriterConfigUnaryOperator).getSql();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -167,6 +162,18 @@ public abstract class SemanticNode {
|
|||||||
return sqlNode;
|
return sqlNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static SqlWriterConfig getSqlWriterConfig(EngineType engineType) {
|
||||||
|
SemanticSqlDialect sqlDialect = SqlDialectFactory.getSqlDialect(engineType);
|
||||||
|
SqlWriterConfig config = SqlPrettyWriter.config().withDialect(sqlDialect)
|
||||||
|
.withKeywordsLowerCase(false).withClauseEndsLine(true).withAlwaysUseParentheses(false)
|
||||||
|
.withSelectListItemsOnSeparateLines(false).withUpdateSetListNewline(false).withIndentation(0);
|
||||||
|
if (EngineType.MYSQL.equals(engineType)) {
|
||||||
|
//no backticks around function name
|
||||||
|
config = config.withQuoteAllIdentifiers(false);
|
||||||
|
}
|
||||||
|
return config;
|
||||||
|
}
|
||||||
|
|
||||||
private static void sqlVisit(SqlNode sqlNode, Map<String, Object> parseInfo) {
|
private static void sqlVisit(SqlNode sqlNode, Map<String, Object> parseInfo) {
|
||||||
SqlKind kind = sqlNode.getKind();
|
SqlKind kind = sqlNode.getKind();
|
||||||
switch (kind) {
|
switch (kind) {
|
||||||
|
|||||||
Reference in New Issue
Block a user