fix(completion): respect identifier quoting for oracle completions

This commit is contained in:
Melody Ruch authored and GitHub committed 2026-09-20 19:10:29 +08:00
1 parent 99d2aa5f13
commit 2a8e329d05
3 files changed
+29 -1

No files matched your search

@@ -70,3 +70,23 @@ describe("oracle completion apply identifiers", () => {
expect(routine?.apply).toBe('"GetBom"()');
});
});
describe("oracle completion with identifier quoting disabled (#9735)", () => {
const sql = "SELECT t.c FROM abc t";
const cursor = "SELECT t.c".length;
const input = {
databaseType: "oracle" as const,
tables: [{ name: "abc", type: "table" as const }],
columnsByTable: new Map([["abc", [{ name: "col1", table: "abc" }]]]),
};
const applyOf = (extra: { quoteIdentifiers?: boolean }) => buildSqlCompletionItems(sql, cursor, { ...input, ...extra }).find((item) => item.label === "col1")?.apply;
it("keeps lowercase columns bare when quoting is disabled", () => {
expect(applyOf({ quoteIdentifiers: false })).toBe("col1");
});
it("still quotes lowercase columns by default and when quoting is enabled", () => {
expect(applyOf({})).toBe('"col1"');
expect(applyOf({ quoteIdentifiers: true })).toBe('"col1"');
});
});
+5 -1
View File
@@ -1548,6 +1548,7 @@ export interface SqlCompletionProviderInput {
keywordCase?: SqlKeywordCase;
functionCase?: SqlKeywordCase;
autoAliasTables?: boolean;
quoteIdentifiers?: boolean;
}
export function buildSqlCompletionItems(
@@ -1567,6 +1568,7 @@ export function buildSqlCompletionItems(
keywordCase?: SqlKeywordCase;
functionCase?: SqlKeywordCase;
autoAliasTables?: boolean;
quoteIdentifiers?: boolean;
},
): SqlCompletionItem[] {
if (isSqlCompletionSuppressedContext(sql, cursor, input)) return [];
@@ -1589,7 +1591,9 @@ class SqlCompletionProvider {
private readonly input: SqlCompletionProviderInput,
) {
this.t = input.translations;
this.dialect = sqlCompletionApplyDialect(input.databaseType, input.dialect);
const dialect = sqlCompletionApplyDialect(input.databaseType, input.dialect);
// "Quote identifiers in generated SQL" off: Oracle completion inserts bare names instead of quoting lowercase ones.
this.dialect = dialect === "oracle" && input.quoteIdentifiers === false ? undefined : dialect;
this.databaseType = input.databaseType;
}