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: fix cargo fmt and update tests for completion/snippet changes

t8y26d35dcfda80b
diff --git a/crates/dbx-core/src/db/duckdb_driver.rs b/crates/dbx-core/src/db/duckdb_driver.rs
index 5d2bfeb8d0..89a5ce857d 100644
--- a/crates/dbx-core/src/db/duckdb_driver.rs
+++ b/crates/dbx-core/src/db/duckdb_driver.rs
@@ -61,16 +61,14 @@ pub fn is_memory_database_path(path: &str) -> bool {
/// On Windows this prevents "file already in use" errors when reconnecting.
pub fn close_connection(con: Arc<Mutex<duckdb::Connection>>) {
match Arc::try_unwrap(con) {
- Ok(mutex) => {
- match mutex.into_inner() {
- Ok(conn) => {
- let _ = conn.close();
- }
- Err(poisoned) => {
- let _ = poisoned.into_inner().close();
- }
+ Ok(mutex) => match mutex.into_inner() {
+ Ok(conn) => {
+ let _ = conn.close();
}
- }
+ Err(poisoned) => {
+ let _ = poisoned.into_inner().close();
+ }
+ },
Err(_) => {
// Arc still referenced elsewhere (e.g. running queries);
// the last holder will drop and close the connection.
diff --git a/packages/app-tests/editorCompletionTheme.test.ts b/packages/app-tests/editorCompletionTheme.test.ts
index a62cbf7e2c..b0b8174f7a 100644
--- a/packages/app-tests/editorCompletionTheme.test.ts
+++ b/packages/app-tests/editorCompletionTheme.test.ts
@@ -57,7 +57,7 @@ test("sql completion theme styles the autocomplete popup", () => {
);
assert.equal(
rules[".cm-completionIcon-snippet"]?.color,
- "color-mix(in oklch, var(--emerald-500, #10b981) 92%, var(--popover-foreground))",
+ "color-mix(in oklch, var(--violet-500, #8b5cf6) 92%, var(--popover-foreground))",
);
assert.deepEqual(rules[".cm-completionLabel"], {
color: "inherit",
diff --git a/packages/app-tests/queryStore.test.ts b/packages/app-tests/queryStore.test.ts
index 3e7c33e5d4..31a97fb00c 100644
--- a/packages/app-tests/queryStore.test.ts
+++ b/packages/app-tests/queryStore.test.ts
@@ -35,7 +35,7 @@ test("setErrorResult stops loading and shows the error result", () => {
assert.equal(tab?.isCancelling, false);
assert.equal(tab?.executionId, undefined);
assert.deepEqual(tab?.result?.columns, ["Error"]);
- assert.deepEqual(tab?.result?.rows, [["Error: metadata failed"]]);
+ assert.deepEqual(tab?.result?.rows, [["metadata failed"]]);
});
test("evicting cached tab results releases multi-result payloads and sessions", async () => {
diff --git a/packages/app-tests/sqlCompletion.test.ts b/packages/app-tests/sqlCompletion.test.ts
index c99a203a7d..2d1f3e84f6 100644
--- a/packages/app-tests/sqlCompletion.test.ts
+++ b/packages/app-tests/sqlCompletion.test.ts
@@ -44,8 +44,9 @@ test("suggests SQL keywords for generic keyword input", () => {
columnsByTable,
});
- assert.equal(items[0]?.label, "SELECT");
- assert.equal(items[0]?.type, "keyword");
+ const keyword = items.find((item) => item.type === "keyword" && item.label === "SELECT");
+ assert.ok(keyword);
+ assert.equal(keyword.type, "keyword");
});
test("suggests matching table names after FROM", () => {
@@ -351,7 +352,7 @@ test("suggests DATE_FORMAT as parameter snippet", () => {
columnsByTable,
});
- const snippet = items.find((item) => item.type === "snippet" && item.label === "DATE_FORMAT");
+ const snippet = items.find((item) => item.type === "function" && item.label === "DATE_FORMAT");
assert.ok(snippet);
assert.equal(snippet.detail, "按指定格式格式化日期");
assert.equal(snippet.apply, "DATE_FORMAT(${date}, ${format})");
@@ -655,7 +656,7 @@ test("suggests ROW_NUMBER with OVER clause", () => {
tables,
columnsByTable,
});
- const rn = items.find((item) => item.label === "ROW_NUMBER" && item.type === "snippet")!;
+ const rn = items.find((item) => item.label === "ROW_NUMBER" && item.type === "function")!;
assert.ok(rn);
assert.ok(rn.apply!.includes("OVER"), "ROW_NUMBER should include OVER()");
assert.ok(rn.apply!.includes("PARTITION BY"), "ROW_NUMBER should include PARTITION BY");
@@ -723,7 +724,7 @@ test("suggests REGEXP_REPLACE with parameters", () => {
tables,
columnsByTable,
});
- const fn = items.find((item) => item.label === "REGEXP_REPLACE" && item.type === "snippet");
+ const fn = items.find((item) => item.label === "REGEXP_REPLACE" && item.type === "function");
assert.ok(fn);
assert.ok(fn.apply!.includes("pattern"), "should include pattern param");
});
@@ -733,7 +734,7 @@ test("suggests JSON_EXTRACT with parameters", () => {
tables,
columnsByTable,
});
- const fn = items.find((item) => item.label === "JSON_EXTRACT" && item.type === "snippet");
+ const fn = items.find((item) => item.label === "JSON_EXTRACT" && item.type === "function");
assert.ok(fn);
assert.ok(fn.apply!.includes("json"), "should include json param");
});