fix(sql): keep GaussDB merge actions in statement range
This commit is contained in:
2 files changed
+46
No files matched your search
@@ -803,6 +803,10 @@ function splitStatementRangeAtSoftStarts(sql: string, statement: RawStatement, d
|
||||
continue;
|
||||
}
|
||||
|
||||
if (currentBodyKeyword === "MERGE" && isMergeActionContinuation(sql, statement.from, lineStart.from, lineStart.keyword, databaseType, parameterOptions)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (currentBodyKeyword === "ALTER" && isClickHouseAlterTableUpdateContinuation(sql, boundaries[boundaries.length - 1].from, lineStart.from, lineStart.keyword, databaseType)) {
|
||||
// ClickHouse mutations use UPDATE as the first ALTER TABLE action, not as
|
||||
// a standalone statement. Keep this dialect-specific to preserve soft boundaries elsewhere.
|
||||
@@ -1068,6 +1072,12 @@ function isMysqlAlterTableTruncatePartitionContinuation(sql: string, statementFr
|
||||
return nextSqlWord(sql, lineStartFrom + keyword.length, databaseType) === "PARTITION";
|
||||
}
|
||||
|
||||
function isMergeActionContinuation(sql: string, statementFrom: number, lineStartFrom: number, keyword: string, databaseType?: DatabaseType, parameterOptions?: SqlParameterOptions): boolean {
|
||||
if (keyword !== "INSERT" || !startsWithSqlWords(sql, statementFrom, ["MERGE"], databaseType, parameterOptions)) return false;
|
||||
const words = topLevelWordsBefore(sql, statementFrom, lineStartFrom, 5, databaseType, parameterOptions);
|
||||
return words[words.length - 1] === "THEN" && words.includes("WHEN") && words.includes("MATCHED");
|
||||
}
|
||||
|
||||
function startsWithMysqlCreateTable(sql: string, statementFrom: number): boolean {
|
||||
const text = sql.slice(statementFrom, statementFrom + 256);
|
||||
return /^CREATE\s+(?:TEMPORARY\s+)?TABLE\b/i.test(text);
|
||||
|
||||
Reference in new issue
Block a user