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(hana): allow empty database context

t8y284e2093b82f2
diff --git a/apps/desktop/src/components/editor/QueryEditor.vue b/apps/desktop/src/components/editor/QueryEditor.vue
index c87bc30737..9cea64115e 100644
--- a/apps/desktop/src/components/editor/QueryEditor.vue
+++ b/apps/desktop/src/components/editor/QueryEditor.vue
@@ -382,7 +382,7 @@ function completionCacheKey(table: { name: string; schema?: string | null }) {
async function ensureColumnsForTable(table: { name: string; schema?: string | null }) {
const cacheKey = completionCacheKey(table);
- if (cachedColumnsByTable.has(cacheKey) || !props.connectionId || !props.database) return;
+ if (cachedColumnsByTable.has(cacheKey) || !props.connectionId || props.database == null) return;
const columns = await connectionStore.listCompletionColumns(
props.connectionId,
props.database,
@@ -453,7 +453,7 @@ function createSignatureDom(signature: ReturnType<typeof getSqlFunctionSignature
}
async function resolveSqlHoverTooltip(currentView: EditorViewType, pos: number) {
- if (!props.connectionId || !props.database) return null;
+ if (!props.connectionId || props.database == null) return null;
const sql = currentView.state.doc.toString();
const range = identifierRangeAt(sql, pos);
@@ -582,7 +582,7 @@ function setSemanticDiagnostics(next: SqlSemanticDiagnostic[]) {
}
async function enrichSemanticDiagnosticTables(tables: SqlTableReference[]) {
- if (!props.connectionId || !props.database) return tables;
+ if (!props.connectionId || props.database == null) return tables;
const enriched: SqlTableReference[] = [];
for (const table of tables) {
@@ -615,7 +615,7 @@ async function enrichSemanticDiagnosticTables(tables: SqlTableReference[]) {
async function refreshSemanticDiagnostics() {
const currentView = view.value;
const runId = ++semanticDiagnosticRunId;
- if (!currentView || !props.connectionId || !props.database) {
+ if (!currentView || !props.connectionId || props.database == null) {
setSemanticDiagnostics([]);
return;
}
@@ -697,7 +697,7 @@ async function provideSqlCompletions(
position: number,
explicit: boolean,
) {
- if (!props.connectionId || !props.database) return null;
+ if (!props.connectionId || props.database == null) return null;
const epoch = ++completionEpoch;
@@ -1254,7 +1254,7 @@ onMounted(async () => {
if (event.button !== 0) return false;
const currentView = view.value;
- if (!currentView || !props.connectionId || !props.database) {
+ if (!currentView || !props.connectionId || props.database == null) {
return false;
}
diff --git a/apps/desktop/src/components/sidebar/TreeItem.vue b/apps/desktop/src/components/sidebar/TreeItem.vue
index 21a94ed892..e8d2e133a8 100644
--- a/apps/desktop/src/components/sidebar/TreeItem.vue
+++ b/apps/desktop/src/components/sidebar/TreeItem.vue
@@ -159,6 +159,10 @@ function currentDatabaseType(): DatabaseType | undefined {
return props.node.connectionId ? connectionStore.getConfig(props.node.connectionId)?.db_type : undefined;
}
+function hasNodeDatabaseContext(node: TreeNode): node is TreeNode & { connectionId: string; database: string } {
+ return !!node.connectionId && hasTreeNodeDatabaseContext(node);
+}
+
function getIconInfo(node: TreeNode): { icon: any; colorClass: string } | null {
switch (node.type) {
case "connection":
@@ -446,7 +450,7 @@ async function openObjectBrowser() {
await connectionStore.ensureConnected(node.connectionId);
connectionStore.activeConnectionId = node.connectionId;
- if (node.database) {
+ if (hasTreeNodeDatabaseContext(node)) {
queryStore.openObjectBrowser(node.connectionId, node.database, node.schema);
return;
}
@@ -482,7 +486,7 @@ function openSavedSqlFile() {
async function openData() {
const node = props.node;
- if (!(node.type === "table" || node.type === "view") || !node.connectionId || !node.database) return;
+ if (!(node.type === "table" || node.type === "view") || !hasNodeDatabaseContext(node)) return;
const config = connectionStore.getConfig(node.connectionId);
const traceId = uuid().slice(0, 8);
const startedAt = performance.now();
@@ -562,7 +566,7 @@ async function newQuery() {
try {
await connectionStore.ensureConnected(node.connectionId);
connectionStore.activeConnectionId = node.connectionId;
- if (node.database) {
+ if (hasTreeNodeDatabaseContext(node)) {
queryStore.createTab(node.connectionId, node.database, undefined, "query", node.schema);
return;
}