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(sql-library): decode imported SQL files

zipg5528f4e22395
diff --git a/apps/desktop/src/components/layout/SqlLibraryPanel.vue b/apps/desktop/src/components/layout/SqlLibraryPanel.vue
index 57174ac252..a8cc8545d3 100644
--- a/apps/desktop/src/components/layout/SqlLibraryPanel.vue
+++ b/apps/desktop/src/components/layout/SqlLibraryPanel.vue
@@ -235,7 +235,6 @@ async function importDirectoryIntoLibrary(targetFolder?: SavedSqlFolder) {
try {
const { open } = await import("@tauri-apps/plugin-dialog");
- const { readTextFile } = await import("@tauri-apps/plugin-fs");
const selected = await open({
directory: true,
multiple: false,
@@ -253,7 +252,7 @@ async function importDirectoryIntoLibrary(targetFolder?: SavedSqlFolder) {
const takenNames = new Set((targetFolder ? savedSqlStore.filesInFolder(targetFolder.id) : savedSqlStore.filesWithoutFolder()).filter((file) => !orphanedIds.value.has(file.id)).map((file) => file.name));
for (const path of sqlPaths) {
- const content = await readTextFile(path);
+ const content = await api.readExternalSqlFile(path);
const displayName = uniqueImportedName(relativeImportName(selected, path), takenNames);
await savedSqlStore.saveFile({
connectionId,
diff --git a/packages/app-tests/sqlLibraryImportEncoding.test.ts b/packages/app-tests/sqlLibraryImportEncoding.test.ts
new file mode 100644
index 0000000000..bcd162df2c
--- /dev/null
+++ b/packages/app-tests/sqlLibraryImportEncoding.test.ts
@@ -0,0 +1,14 @@
+import assert from "node:assert/strict";
+import { readFileSync } from "node:fs";
+import { test } from "vitest";
+
+const source = readFileSync("apps/desktop/src/components/layout/SqlLibraryPanel.vue", "utf8");
+
+test("SQL library imports use the charset-aware external SQL reader", () => {
+ const start = source.indexOf("async function importDirectoryIntoLibrary");
+ const end = source.indexOf("async function chooseSyncDirectory", start);
+ const handler = start >= 0 && end > start ? source.slice(start, end) : "";
+
+ assert.match(handler, /await api\.readExternalSqlFile\(path\)/);
+ assert.doesNotMatch(handler, /readTextFile/);
+});