fix(editor): 修复 MySQL DUAL、SYSDATE 提示和额外间距
This commit is contained in:
5 files changed
+73
-7
No files matched your search
@@ -15,6 +15,7 @@ export interface SqlSemanticDiagnosticSchema {
|
||||
missingTables?: Set<string>;
|
||||
loadedColumnTables?: Set<string>;
|
||||
sql?: string;
|
||||
databaseType?: DatabaseType;
|
||||
}
|
||||
|
||||
export interface SqlSemanticDiagnosticVisibleRange {
|
||||
@@ -52,6 +53,7 @@ export function buildSqlSemanticDiagnostics(analysis: SqlReferenceAnalysis, sche
|
||||
}
|
||||
|
||||
for (const table of tables) {
|
||||
if (isSqlVirtualTableReference(table, schema.databaseType)) continue;
|
||||
if (!schema.missingTables?.has(tableReferenceKey(table))) continue;
|
||||
diagnostics.push({
|
||||
span: trimSqlTextSpanWhitespace(schema.sql, table.span),
|
||||
@@ -82,6 +84,10 @@ export function buildSqlSemanticDiagnostics(analysis: SqlReferenceAnalysis, sche
|
||||
return diagnostics;
|
||||
}
|
||||
|
||||
export function isSqlVirtualTableReference(table: { name: string; schema?: string | null }, databaseType?: DatabaseType): boolean {
|
||||
return databaseType === "mysql" && !table.schema && normalizeName(table.name) === "dual";
|
||||
}
|
||||
|
||||
function trimSqlTextSpanWhitespace(sql: string | undefined, span: SqlTextSpan): SqlTextSpan {
|
||||
if (!sql) return span;
|
||||
const range = sqlTextSpanToOffsetRange(sql, span);
|
||||
|
||||
@@ -958,6 +958,7 @@ const MYSQL_FUNCTION_SIGNATURES = new Map<string, string[]>([
|
||||
["DATE_FORMAT", ["date", "format"]],
|
||||
["FROM_UNIXTIME", ["unix_timestamp"]],
|
||||
["UNIX_TIMESTAMP", []],
|
||||
["SYSDATE", []],
|
||||
["JSON_EXTRACT", ["json", "path"]],
|
||||
["JSON_UNQUOTE", ["json"]],
|
||||
["GROUP_CONCAT", ["expression"]],
|
||||
|
||||
Reference in new issue
Block a user