fix(sql): support Oracle system value completion
This commit is contained in:
3 files changed
+117
-1
No files matched your search
@@ -1,5 +1,5 @@
|
||||
import type { SqlCompletionColumn, SqlCompletionTable } from "@/lib/sql/sqlCompletion";
|
||||
import { getSqlCompletionContext } from "@/lib/sql/sqlCompletion";
|
||||
import { getSqlCompletionContext, isOracleSystemValueName } from "@/lib/sql/sqlCompletion";
|
||||
import { executableStatementRanges, isOraclePlSqlStatement, type SqlTextRange } from "@/lib/sql/sqlStatementRanges";
|
||||
import type { DatabaseType, SqlColumnReference, SqlReferenceAnalysis, SqlReferenceScope, SqlTableReference, SqlTextSpan } from "@/types/database";
|
||||
|
||||
@@ -63,6 +63,7 @@ export function buildSqlSemanticDiagnostics(analysis: SqlReferenceAnalysis, sche
|
||||
}
|
||||
|
||||
for (const column of analysis.columns) {
|
||||
if (isUnquotedOracleSystemValueReference(column, schema)) continue;
|
||||
const table = resolveColumnTable(column, tables, knownTables, schema.sql, scopesById);
|
||||
if (!table) continue;
|
||||
if (schema.missingTables?.has(tableReferenceKey(table))) continue;
|
||||
@@ -84,6 +85,16 @@ export function buildSqlSemanticDiagnostics(analysis: SqlReferenceAnalysis, sche
|
||||
return diagnostics;
|
||||
}
|
||||
|
||||
function isUnquotedOracleSystemValueReference(column: SqlColumnReference, schema: SqlSemanticDiagnosticSchema): boolean {
|
||||
if (column.qualifier || !isOracleSystemValueName(column.name, schema.databaseType)) return false;
|
||||
if (!schema.sql) return false;
|
||||
|
||||
const range = sqlTextSpanToOffsetRange(schema.sql, column.span);
|
||||
if (!range) return false;
|
||||
const firstCharacter = schema.sql.slice(range.from, range.to).trimStart()[0];
|
||||
return firstCharacter !== '"' && firstCharacter !== "'" && firstCharacter !== "`" && firstCharacter !== "[";
|
||||
}
|
||||
|
||||
export function isSqlVirtualTableReference(table: { name: string; schema?: string | null }, databaseType?: DatabaseType): boolean {
|
||||
return databaseType === "mysql" && !table.schema && normalizeName(table.name) === "dual";
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user