Skip to content

armgit / dbx

Public Imported from GitHub
0

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。

feat(editor): filter schema selector options

t8y215546387dbbb
diff --git a/apps/desktop/src/composables/useSchemaOptions.ts b/apps/desktop/src/composables/useSchemaOptions.ts
index 764b849619..07cf3f6ce5 100644
--- a/apps/desktop/src/composables/useSchemaOptions.ts
+++ b/apps/desktop/src/composables/useSchemaOptions.ts
@@ -1,12 +1,18 @@
import { ref } from "vue";
import { useConnectionStore } from "@/stores/connectionStore";
import { isSchemaAware as isSchemaAwareType, isSingleDatabase, usesTreeSchemaMode } from "@/lib/databaseCapabilities";
+import { filterDatabaseNamesForConnection } from "@/lib/visibleDatabases";
+import type { ConnectionConfig } from "@/types/database";
import * as api from "@/lib/api";
export function hasSchemaOptionsCacheEntry(options: Record<string, string[]>, key: string): boolean {
return Object.prototype.hasOwnProperty.call(options, key);
}
+export function schemaOptionsForConnection(schemaNames: string[], connection: Pick<ConnectionConfig, "db_type" | "driver_profile" | "visible_databases"> | undefined): string[] {
+ return filterDatabaseNamesForConnection(schemaNames, connection);
+}
+
export function useSchemaOptions() {
const connectionStore = useConnectionStore();
@@ -23,7 +29,8 @@ export function useSchemaOptions() {
async function loadSchemaOptions(connectionId: string, database: string) {
if (!isSchemaAware(connectionId)) return;
- const dbType = connectionStore.getConfig(connectionId)?.db_type;
+ const connection = connectionStore.getConfig(connectionId);
+ const dbType = connection?.db_type;
if (!database && !isSingleDatabase(dbType) && !usesTreeSchemaMode(dbType)) return;
const key = cacheKey(connectionId, database);
if (hasSchemaOptionsCacheEntry(schemaOptions.value, key)) return;
@@ -32,7 +39,7 @@ export function useSchemaOptions() {
loadingSchemaOptions.value[key] = true;
try {
await connectionStore.ensureConnected(connectionId);
- schemaOptions.value[key] = await api.listSchemas(connectionId, database);
+ schemaOptions.value[key] = schemaOptionsForConnection(await api.listSchemas(connectionId, database), connection);
} catch (e) {
schemaOptions.value[key] = [];
throw e;
diff --git a/packages/app-tests/schemaOptions.test.ts b/packages/app-tests/schemaOptions.test.ts
new file mode 100644
index 0000000000..eee8443823
--- /dev/null
+++ b/packages/app-tests/schemaOptions.test.ts
@@ -0,0 +1,23 @@
+import assert from "node:assert/strict";
+import { test } from "vitest";
+import { schemaOptionsForConnection } from "../../apps/desktop/src/composables/useSchemaOptions.ts";
+
+test("schema options respect Oracle visible database filters", () => {
+ assert.deepEqual(
+ schemaOptionsForConnection(["CAM", "00010", "00012", "SYS"], {
+ db_type: "oracle",
+ visible_databases: ["CAM", "00010"],
+ }),
+ ["CAM", "00010"],
+ );
+});
+
+test("schema options keep default system-schema filtering without explicit filters", () => {
+ assert.deepEqual(
+ schemaOptionsForConnection(["CAM", "SYS", "SYSTEM"], {
+ db_type: "oracle",
+ visible_databases: undefined,
+ }),
+ ["CAM"],
+ );
+});