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。

fix(ui): propagate schema when creating tabs and new queries

t8y27b9a04ff3e18
diff --git a/apps/desktop/src/App.vue b/apps/desktop/src/App.vue
index fee10312b6..50902f4180 100644
--- a/apps/desktop/src/App.vue
+++ b/apps/desktop/src/App.vue
@@ -473,7 +473,7 @@ async function newQuery() {
const conn = connectionStore.getConfig(target.connectionId);
if (!conn) return;
connectionStore.activeConnectionId = target.connectionId;
- const tabId = queryStore.createTab(conn.id, target.database);
+ const tabId = queryStore.createTab(conn.id, target.database, undefined, "query", target.schema);
try {
await connectionStore.ensureConnected(target.connectionId);
if (target.shouldRefreshDefaultDatabase) {
diff --git a/apps/desktop/src/components/sidebar/TreeItem.vue b/apps/desktop/src/components/sidebar/TreeItem.vue
index 5298443331..0c9eda1fca 100644
--- a/apps/desktop/src/components/sidebar/TreeItem.vue
+++ b/apps/desktop/src/components/sidebar/TreeItem.vue
@@ -494,7 +494,7 @@ async function openData() {
table: node.label,
dbType: config?.db_type,
});
- const tabId = queryStore.createTab(node.connectionId, node.database, node.label, "data");
+ const tabId = queryStore.createTab(node.connectionId, node.database, node.label, "data", node.schema);
console.info("[DBX][openData:tab-created]", { traceId, tabId, elapsed: elapsed() });
queryStore.setExecuting(tabId, true);
diff --git a/apps/desktop/src/composables/useNavigationTargets.ts b/apps/desktop/src/composables/useNavigationTargets.ts
index 423e9588ce..4574789d3f 100644
--- a/apps/desktop/src/composables/useNavigationTargets.ts
+++ b/apps/desktop/src/composables/useNavigationTargets.ts
@@ -23,7 +23,7 @@ async function openTableTarget(target: NavigationTarget) {
connectionStore.activeConnectionId = target.connectionId;
const config = connectionStore.getConfig(target.connectionId);
const tabTitle = target.schema ? `${target.schema}.${target.tableName}` : target.tableName;
- const tabId = queryStore.createTab(target.connectionId, target.database, tabTitle, "data");
+ const tabId = queryStore.createTab(target.connectionId, target.database, tabTitle, "data", target.schema);
queryStore.setExecuting(tabId, true);
try {
diff --git a/apps/desktop/src/lib/newQueryContext.ts b/apps/desktop/src/lib/newQueryContext.ts
index fc7bf87222..4981f9aa52 100644
--- a/apps/desktop/src/lib/newQueryContext.ts
+++ b/apps/desktop/src/lib/newQueryContext.ts
@@ -4,14 +4,15 @@ import type { ConnectionConfig, QueryTab, TreeNode } from "@/types/database";
export interface NewQueryTarget {
connectionId: string;
database: string;
+ schema?: string;
shouldRefreshDefaultDatabase: boolean;
}
export type NewQueryContextSource = "tab" | "sidebar";
interface ResolveNewQueryTargetInput {
- activeTab?: Pick<QueryTab, "connectionId" | "database">;
- selectedTreeNode?: Pick<TreeNode, "connectionId" | "database"> | null;
+ activeTab?: Pick<QueryTab, "connectionId" | "database" | "schema">;
+ selectedTreeNode?: Pick<TreeNode, "connectionId" | "database" | "schema"> | null;
activeConnectionId?: string | null;
connections: Pick<ConnectionConfig, "id" | "database">[];
preferredSource?: NewQueryContextSource;
@@ -49,7 +50,7 @@ export function resolveNewQueryTarget(input: ResolveNewQueryTargetInput): NewQue
}
function targetFromContext(
- context: Pick<QueryTab | TreeNode, "connectionId" | "database"> | undefined,
+ context: Pick<QueryTab | TreeNode, "connectionId" | "database" | "schema"> | undefined,
connections: Pick<ConnectionConfig, "id" | "database">[],
): NewQueryTarget | null {
if (!context?.connectionId) return null;
@@ -59,6 +60,7 @@ function targetFromContext(
return {
connectionId: context.connectionId,
database,
+ schema: "schema" in context ? (context as { schema?: string }).schema : undefined,
shouldRefreshDefaultDatabase: !context.database,
};
}