Skip to content

Commit

Permalink
Merge pull request #163 from Ghoughpteighbteau/master
Browse files Browse the repository at this point in the history
Add order to column generation to improve schema consistency
  • Loading branch information
jawj authored Feb 21, 2024
2 parents bc61cde + 2e9ea86 commit 3213670
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/generate/tables.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ const columnsForRelation = async (rel: Relation, schemaName: string, queryFn: (q
LEFT JOIN pg_catalog.pg_type t1 ON t1.oid = a.atttypid
LEFT JOIN pg_catalog.pg_type t2 ON t2.oid = t1.typbasetype
LEFT JOIN pg_catalog.pg_description d ON d.objoid = c.oid AND d.objsubid = a.attnum
WHERE c.relkind = 'm' AND a.attnum >= 1 AND c.relname = $1 AND n.nspname = $2`
WHERE c.relkind = 'm' AND a.attnum >= 1 AND c.relname = $1 AND n.nspname = $2
ORDER BY "column"`
: `
SELECT
column_name AS "column"
Expand All @@ -82,7 +83,8 @@ const columnsForRelation = async (rel: Relation, schemaName: string, queryFn: (q
LEFT JOIN pg_catalog.pg_namespace ns ON ns.nspname = c.table_schema
LEFT JOIN pg_catalog.pg_class cl ON cl.relkind = 'r' AND cl.relname = c.table_name AND cl.relnamespace = ns.oid
LEFT JOIN pg_catalog.pg_description d ON d.objoid = cl.oid AND d.objsubid = c.ordinal_position
WHERE c.table_name = $1 AND c.table_schema = $2`,
WHERE c.table_name = $1 AND c.table_schema = $2
ORDER BY "column"`,
values: [rel.name, schemaName],
});

Expand Down

0 comments on commit 3213670

Please sign in to comment.