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(editor): complete MySQL date functions
zipg8c11f2efaaff
diff --git a/apps/desktop/src/lib/__tests__/sql/sqlCompletion.context.spec.ts b/apps/desktop/src/lib/__tests__/sql/sqlCompletion.context.spec.tsindex dd414139c9..b460b6473c 100644--- a/apps/desktop/src/lib/__tests__/sql/sqlCompletion.context.spec.ts+++ b/apps/desktop/src/lib/__tests__/sql/sqlCompletion.context.spec.ts@@ -14,6 +14,64 @@ describe("sqlCompletion keyword snippets", () => {});});+describe("sqlCompletion database functions", () => {+ it("suggests MySQL Unix timestamp functions with function snippets", () => {+ const fromUnixSql = "SELECT from_unix";+ const fromUnixItems = buildSqlCompletionItems(fromUnixSql, fromUnixSql.length, {+ databaseType: "mysql",+ tables: [],+ columnsByTable: new Map(),+ });+ const fromUnixTime = fromUnixItems.find((item) => item.label === "FROM_UNIXTIME");++ expect(fromUnixItems[0]).toBe(fromUnixTime);+ expect(fromUnixTime).toEqual(+ expect.objectContaining({+ type: "function",+ apply: "FROM_UNIXTIME(${unix_timestamp})",+ }),+ );++ const unixTimestampSql = "SELECT unix_time";+ const unixTimestampItems = buildSqlCompletionItems(unixTimestampSql, unixTimestampSql.length, {+ databaseType: "mysql",+ tables: [],+ columnsByTable: new Map(),+ });++ expect(unixTimestampItems[0]).toEqual(+ expect.objectContaining({+ label: "UNIX_TIMESTAMP",+ type: "function",+ apply: "UNIX_TIMESTAMP()",+ }),+ );+ });++ it("ranks MySQL function prefixes ahead of ordinary keyword prefixes", () => {+ const sql = "SELECT uni";+ const items = buildSqlCompletionItems(sql, sql.length, {+ databaseType: "mysql",+ tables: [],+ columnsByTable: new Map(),+ });++ expect(items.some((item) => item.type === "keyword")).toBe(true);+ expect(items[0]).toEqual(expect.objectContaining({ label: "UNIX_TIMESTAMP", type: "function" }));+ });++ it("does not expose MySQL-only functions to other databases", () => {+ const sql = "SELECT from_unix";+ const items = buildSqlCompletionItems(sql, sql.length, {+ databaseType: "postgres",+ tables: [],+ columnsByTable: new Map(),+ });++ expect(items.some((item) => item.label === "FROM_UNIXTIME")).toBe(false);+ });+});+describe("sqlCompletion quoted schema qualifiers", () => {it("parses quoted PostgreSQL schema names before a dot", () => {const sql = 'SELECT *\nFROM "order-management".';diff --git a/apps/desktop/src/lib/sql/sqlCompletion.ts b/apps/desktop/src/lib/sql/sqlCompletion.tsindex 3212bf27ca..ae1de8152f 100644--- a/apps/desktop/src/lib/sql/sqlCompletion.ts+++ b/apps/desktop/src/lib/sql/sqlCompletion.ts@@ -883,6 +883,8 @@ const POSTGRES_FUNCTION_SIGNATURES = new Map<string, string[]>([const MYSQL_FUNCTION_SIGNATURES = new Map<string, string[]>([["DATE_FORMAT", ["date", "format"]],+ ["FROM_UNIXTIME", ["unix_timestamp"]],+ ["UNIX_TIMESTAMP", []],["JSON_EXTRACT", ["json", "path"]],["JSON_UNQUOTE", ["json"]],["GROUP_CONCAT", ["expression"]],