1 parent
ec50662793
commit
c210efbcc5
4 files changed
+204
-2
No files matched your search
@@ -231,6 +231,8 @@ const COMMON_SOFT_STATEMENT_START_KEYWORDS = [
|
||||
"COPY",
|
||||
] as const;
|
||||
|
||||
const SOFT_STATEMENT_FUNCTION_KEYWORDS = new Set(["REPLACE", "TRUNCATE"]);
|
||||
|
||||
const DATABASE_SOFT_STATEMENT_KEYWORDS: Partial<Record<DatabaseType, readonly string[]>> = {
|
||||
mysql: ["HANDLER", "LOAD", "OPTIMIZE", "REPAIR"],
|
||||
postgres: ["DO", "LISTEN", "NOTIFY", "UNLISTEN"],
|
||||
@@ -957,7 +959,7 @@ function softStatementKeywordAt(sql: string, pos: number, databaseType?: Databas
|
||||
const match = /^[A-Za-z_][\w$]*/.exec(sql.slice(pos));
|
||||
if (!match) return null;
|
||||
const keyword = match[0].toUpperCase();
|
||||
if (keyword === "REPLACE" && nextNonWhitespaceChar(sql, pos + match[0].length) === "(") return null;
|
||||
if (SOFT_STATEMENT_FUNCTION_KEYWORDS.has(keyword) && nextNonWhitespaceChar(sql, pos + match[0].length) === "(") return null;
|
||||
// COMMENT is also a common column name. Only COMMENT ON starts a standalone
|
||||
// SQL command; otherwise a line-start projection column must stay in SELECT.
|
||||
if (keyword === "COMMENT" && nextSqlWord(sql, pos + match[0].length, databaseType, parameterOptions) !== "ON") return null;
|
||||
|
||||
Reference in new issue
Block a user