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
feat(editor): naturally sort schema options
t8y2a9428e3c7333
diff --git a/apps/desktop/src/composables/__tests__/useSchemaOptions.spec.ts b/apps/desktop/src/composables/__tests__/useSchemaOptions.spec.tsnew file mode 100644index 0000000000..59c2b7ad12--- /dev/null+++ b/apps/desktop/src/composables/__tests__/useSchemaOptions.spec.ts@@ -0,0 +1,22 @@+import { describe, expect, it } from "vitest";+import { schemaOptionsForConnection } from "@/composables/useSchemaOptions";++describe("schemaOptionsForConnection", () => {+ it("sorts schema names with numeric suffixes naturally", () => {+ const schemaNames = ["WMWMSE16", "WMWMSE17", "WMWMSE18", "WMWMSE19", "WMWMSE2", "WMWMSE20", "WMWMSE1", "WMWMSE10"];++ expect(schemaOptionsForConnection(schemaNames, undefined)).toEqual(["WMWMSE1", "WMWMSE2", "WMWMSE10", "WMWMSE16", "WMWMSE17", "WMWMSE18", "WMWMSE19", "WMWMSE20"]);+ expect(schemaNames).toEqual(["WMWMSE16", "WMWMSE17", "WMWMSE18", "WMWMSE19", "WMWMSE2", "WMWMSE20", "WMWMSE1", "WMWMSE10"]);+ });++ it("sorts after applying the visible schema filter", () => {+ const connection = {+ db_type: "oracle" as const,+ visible_schemas: {+ ORCL: ["WMWMSE10", "WMWMSE2"],+ },+ };++ expect(schemaOptionsForConnection(["WMWMSE10", "SYSTEM", "WMWMSE2", "WMWMSE1"], connection, "ORCL")).toEqual(["WMWMSE2", "WMWMSE10"]);+ });+});diff --git a/apps/desktop/src/composables/useSchemaOptions.ts b/apps/desktop/src/composables/useSchemaOptions.tsindex cc204ddfda..04155472e6 100644--- a/apps/desktop/src/composables/useSchemaOptions.ts+++ b/apps/desktop/src/composables/useSchemaOptions.ts@@ -1,6 +1,7 @@import { ref } from "vue";import { useConnectionStore } from "@/stores/connectionStore";import { isSchemaAware as isSchemaAwareType, isSingleDatabase, usesTreeSchemaMode } from "@/lib/database/databaseCapabilities";+import { sortSidebarNames } from "@/lib/database/databaseTree";import { filterSchemaNamesForConnection } from "@/lib/database/visibleDatabases";import type { ConnectionConfig } from "@/types/database";import * as api from "@/lib/backend/api";@@ -10,7 +11,8 @@ export function hasSchemaOptionsCacheEntry(options: Record<string, string[]>, ke}export function schemaOptionsForConnection(schemaNames: string[], connection: Pick<ConnectionConfig, "db_type" | "driver_profile" | "visible_databases" | "visible_schemas"> | undefined, database = ""): string[] {- return filterSchemaNamesForConnection(schemaNames, connection, database);+ // Keep numeric schema suffixes in human order (SCHEMA2 before SCHEMA10), matching the database tree.+ return sortSidebarNames(filterSchemaNamesForConnection(schemaNames, connection, database));}export function useSchemaOptions() {diff --git a/packages/app-tests/schemaOptions.test.ts b/packages/app-tests/schemaOptions.test.tsindex 3ad7c85b0a..6f1906e085 100644--- a/packages/app-tests/schemaOptions.test.ts+++ b/packages/app-tests/schemaOptions.test.ts@@ -8,7 +8,7 @@ test("schema options respect Oracle visible database filters", () => {db_type: "oracle",visible_databases: ["CAM", "00010"],}),- ["CAM", "00010"],+ ["00010", "CAM"],);});