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(postgres): remove trailing comma in SQL query for table comments

t8y2ccfc3cf92c01
diff --git a/crates/dbx-core/src/db/postgres.rs b/crates/dbx-core/src/db/postgres.rs
index 7061942b03..957296dc77 100644
--- a/crates/dbx-core/src/db/postgres.rs
+++ b/crates/dbx-core/src/db/postgres.rs
@@ -220,7 +220,7 @@ fn postgres_tables_sql() -> &'static str {
CASE c.relkind WHEN 'r' THEN 'BASE TABLE' WHEN 'v' THEN 'VIEW' \
WHEN 'm' THEN 'MATERIALIZED VIEW' WHEN 'f' THEN 'FOREIGN TABLE' \
WHEN 'p' THEN 'BASE TABLE' END AS table_type, \
- obj_description(c.oid) AS table_comment, \
+ obj_description(c.oid) AS table_comment \
FROM pg_catalog.pg_class c \
JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace \
WHERE n.nspname = $1 AND c.relkind IN ('r','v','m','f','p') \
diff --git a/packages/app-tests/postgresSchemaSqlSource.test.ts b/packages/app-tests/postgresSchemaSqlSource.test.ts
new file mode 100644
index 0000000000..610df2ac24
--- /dev/null
+++ b/packages/app-tests/postgresSchemaSqlSource.test.ts
@@ -0,0 +1,10 @@
+import assert from "node:assert/strict";
+import { readFileSync } from "node:fs";
+import test from "node:test";
+
+const source = readFileSync("crates/dbx-core/src/db/postgres.rs", "utf8");
+
+test("postgres table list SQL has no trailing comma before FROM", () => {
+ assert.doesNotMatch(source, /AS table_comment,\s*\\\s*FROM pg_catalog\.pg_class/);
+ assert.match(source, /obj_description\(c\.oid\) AS table_comment\s*\\\s*FROM pg_catalog\.pg_class/);
+});