25 MB lightweight cross-platform database client for 100+ databases, including MySQL, PostgreSQL, SQLite, Redis, MongoDB, DuckDB, SQL Server, and Dameng. Built-in AI, MCP Server, CLI, desktop and Docker. | 轻量级跨平台数据库管理工具,支持 MySQL、PostgreSQL、SQLite、Redis、MongoDB、达梦等 100+ 数据库,提供桌面端、Docker、CLI、内置 AI 助手和 MCP。
TypeScript aicliclickhousedatabasedatabase-clientdatabase-managementdockerguimcpmongodbmysqlpostgresqlredisrustsql-serversqlitetaurivue
fix(oceanbase): preserve required quoting in Oracle-mode templates
efeireec42060ddf38
diff --git a/apps/desktop/src/lib/__tests__/sql/sqlCompletion.context.spec.ts b/apps/desktop/src/lib/__tests__/sql/sqlCompletion.context.spec.tsindex 3e0bb0ff1a..35b83bec0c 100644--- a/apps/desktop/src/lib/__tests__/sql/sqlCompletion.context.spec.ts+++ b/apps/desktop/src/lib/__tests__/sql/sqlCompletion.context.spec.ts@@ -681,6 +681,8 @@ describe("SELECT star expansion", () => {it.each([["oracle", "mysql"],["oracle", undefined],+ ["oceanbase-oracle", "mysql"],+ ["oceanbase-oracle", undefined],[undefined, "oracle"],] as const)("preserves required Oracle column quotes with databaseType %s and dialect %s", (databaseType, dialect) => {const columnsByTable = new Map([["orders", ["OrderId", "order_id", "AGENT_NAME", "SELECT", "created at", "ACCOUNT$SYS"].map((name) => ({ name, table: "orders" }))]]);diff --git a/apps/desktop/src/lib/__tests__/table/tableSelectSql.spec.ts b/apps/desktop/src/lib/__tests__/table/tableSelectSql.spec.tsindex 307206adde..9a3acf23df 100644--- a/apps/desktop/src/lib/__tests__/table/tableSelectSql.spec.ts+++ b/apps/desktop/src/lib/__tests__/table/tableSelectSql.spec.ts@@ -286,6 +286,10 @@ describe("quoteTableIdentifier", () => {expect(quoteTableIdentifierIfNeeded("oracle", "DBX_TEST")).toBe("DBX_TEST");expect(quoteTableIdentifierIfNeeded("oracle", "Order")).toBe('"Order"');expect(quoteTableIdentifierIfNeeded("oracle", "ORDER")).toBe('"ORDER"');+ expect(quoteTableIdentifierIfNeeded("oceanbase-oracle", "DBX_TEST")).toBe("DBX_TEST");+ expect(quoteTableIdentifierIfNeeded("oceanbase-oracle", "Order")).toBe('"Order"');+ expect(quoteTableIdentifierIfNeeded("oceanbase-oracle", "order_id")).toBe('"order_id"');+ expect(quoteTableIdentifierIfNeeded("oceanbase-oracle", "ORDER")).toBe('"ORDER"');expect(quoteTableIdentifierIfNeeded("dameng", "DBX_TEST")).toBe("DBX_TEST");expect(quoteTableIdentifierIfNeeded("dameng", "order detail")).toBe('"order detail"');expect(quoteTableIdentifierIfNeeded("postgres", "dbx_test")).toBe("dbx_test");diff --git a/apps/desktop/src/lib/__tests__/table/tableSqlTemplates.spec.ts b/apps/desktop/src/lib/__tests__/table/tableSqlTemplates.spec.tsindex 2bc4e327cc..d83b771865 100644--- a/apps/desktop/src/lib/__tests__/table/tableSqlTemplates.spec.ts+++ b/apps/desktop/src/lib/__tests__/table/tableSqlTemplates.spec.ts@@ -1,6 +1,6 @@import { describe, expect, it } from "vitest";-import { buildTableSelectTemplate, buildTableUpdateTemplate } from "@/lib/table/tableSqlTemplates";+import { buildTableDeleteTemplate, buildTableSelectTemplate, buildTableUpdateTemplate } from "@/lib/table/tableSqlTemplates";describe("buildTableSelectTemplate", () => {it("can omit identifier quotes for a new-query table reference", () => {@@ -42,3 +42,21 @@ describe("buildTableSelectTemplate", () => {).toBe("UPDATE DBX_TEST\nSET \"ORDER\" = 'ORDER_value'\nWHERE ID = 0;");});});++describe.each(["oracle", "oceanbase-oracle"] as const)("%s table template identifier policy", (databaseType) => {+ it.each([+ [false, '"id", "OrderId", AGENT_NAME, "SELECT", "created at", "A""B"', '"OrderId" = 0,\n AGENT_NAME = 0,\n "SELECT" = 0,\n "created at" = 0,\n "A""B" = 0'],+ [true, '"id", "OrderId", "AGENT_NAME", "SELECT", "created at", "A""B"', '"OrderId" = 0,\n "AGENT_NAME" = 0,\n "SELECT" = 0,\n "created at" = 0,\n "A""B" = 0'],+ ] as const)("preserves object names with quoteIdentifiers=%s", (quoteIdentifiers, selectColumns, assignments) => {+ const options = {+ databaseType,+ schema: "App",+ tableName: "Orders",+ columns: ["id", "OrderId", "AGENT_NAME", "SELECT", "created at", 'A"B'].map((name) => ({ name, data_type: "NUMBER", is_primary_key: name === "id" })),+ quoteIdentifiers,+ };+ expect(buildTableSelectTemplate(options)).toBe(`SELECT ${selectColumns}\nFROM "App"."Orders";`);+ expect(buildTableUpdateTemplate(options)).toBe(`UPDATE "App"."Orders"\nSET ${assignments}\nWHERE "id" = 0;`);+ expect(buildTableDeleteTemplate(options)).toBe('DELETE FROM "App"."Orders"\nWHERE "id" = 0;');+ });+});diff --git a/apps/desktop/src/lib/sql/sqlCompletion.ts b/apps/desktop/src/lib/sql/sqlCompletion.tsindex 9d502b7bf8..e76ebc8273 100644--- a/apps/desktop/src/lib/sql/sqlCompletion.ts+++ b/apps/desktop/src/lib/sql/sqlCompletion.ts@@ -4157,7 +4157,7 @@ function quoteCompletionRoutineName(applyName: string, dialect?: SqlCompletionAp}function quoteSelectStarColumnIdentifier(identifier: string, dialect?: SqlCompletionApplyDialect, databaseType?: DatabaseType): string {- if (databaseType === "oracle" || (databaseType === undefined && dialect === "oracle")) return quoteTableIdentifierIfNeeded("oracle", identifier);+ if (databaseType === "oracle" || databaseType === "oceanbase-oracle" || (databaseType === undefined && dialect === "oracle")) return quoteTableIdentifierIfNeeded("oracle", identifier);if (!requiresPostgresIdentifierQuote(identifier, POSTGRES_IDENTIFIER_KEYWORDS)) return identifier;if (databaseType) return quoteTableIdentifier(databaseType, identifier);if (dialect === "mysql") return `\`${identifier.replaceAll("`", "``")}\``;diff --git a/apps/desktop/src/lib/table/tableSelectSql.ts b/apps/desktop/src/lib/table/tableSelectSql.tsindex 2ef8c9169a..a7139babb3 100644--- a/apps/desktop/src/lib/table/tableSelectSql.ts+++ b/apps/desktop/src/lib/table/tableSelectSql.ts@@ -166,6 +166,7 @@ function requiresIdentifierQuote(databaseType: DatabaseType | undefined, name: scase "goldendb":return requiresMysqlIdentifierQuote(name);case "oracle":+ case "oceanbase-oracle":return requiresOracleIdentifierQuote(name);case "dameng":return requiresDamengIdentifierQuote(name);