diff --git a/apps/desktop/src/components/editor/QueryEditor.vue b/apps/desktop/src/components/editor/QueryEditor.vue index 9c667c827f..261f5c77d1 100644 --- a/apps/desktop/src/components/editor/QueryEditor.vue +++ b/apps/desktop/src/components/editor/QueryEditor.vue @@ -5292,6 +5292,7 @@ async function provideSqlCompletions(context: CompletionContext) { keywordCase: settingsStore.editorSettings.sqlFormatter.keywordCase, functionCase: settingsStore.editorSettings.sqlFormatter.functionCase, autoAliasTables: settingsStore.editorSettings.autoAliasTables, + quoteIdentifiers: settingsStore.editorSettings.generateSqlQuoteIdentifiers, }); return buildSqlCompletionResult(items, completionContext, fullDoc, position); } @@ -5353,6 +5354,7 @@ async function provideSqlCompletions(context: CompletionContext) { keywordCase: settingsStore.editorSettings.sqlFormatter.keywordCase, functionCase: settingsStore.editorSettings.sqlFormatter.functionCase, autoAliasTables: settingsStore.editorSettings.autoAliasTables, + quoteIdentifiers: settingsStore.editorSettings.generateSqlQuoteIdentifiers, }); return buildSqlCompletionResult(items, completionContext, fullDoc, position); } @@ -5693,6 +5695,7 @@ function buildLocalSqlCompletionResult(completionContext: ReturnType { 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"'); + }); +}); diff --git a/apps/desktop/src/lib/sql/sqlCompletion.ts b/apps/desktop/src/lib/sql/sqlCompletion.ts index 1d4d04f920..97fe30b44b 100644 --- a/apps/desktop/src/lib/sql/sqlCompletion.ts +++ b/apps/desktop/src/lib/sql/sqlCompletion.ts @@ -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; }