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/); +});