fix: goctl pg gen will extract all fields when the same table name exists in different schemas (#3496) (#3517)

master
POABOB 1 year ago committed by GitHub
parent c4ef9ceb68
commit 33f6d7ebb8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -72,7 +72,8 @@ from (
t.typname AS type, t.typname AS type,
a.atttypmod AS lengthvar, a.atttypmod AS lengthvar,
a.attnotnull AS not_null, a.attnotnull AS not_null,
b.description AS comment b.description AS comment,
(c.relnamespace::regnamespace)::varchar AS schema_name
FROM pg_class c, FROM pg_class c,
pg_attribute a pg_attribute a
LEFT OUTER JOIN pg_description b ON a.attrelid = b.objoid AND a.attnum = b.objsubid, LEFT OUTER JOIN pg_description b ON a.attrelid = b.objoid AND a.attnum = b.objsubid,
@ -81,10 +82,11 @@ from (
and a.attnum > 0 and a.attnum > 0
and a.attrelid = c.oid and a.attrelid = c.oid
and a.atttypid = t.oid and a.atttypid = t.oid
GROUP BY a.attnum, c.relname, a.attname, t.typname, a.atttypmod, a.attnotnull, b.description GROUP BY a.attnum, c.relname, a.attname, t.typname, a.atttypmod, a.attnotnull, b.description, c.relnamespace::regnamespace
ORDER BY a.attnum) AS t ORDER BY a.attnum) AS t
left join information_schema.columns AS c on t.relname = c.table_name left join information_schema.columns AS c on t.relname = c.table_name and t.schema_name = c.table_schema
and t.field = c.column_name and c.table_schema = $2` and t.field = c.column_name
where c.table_schema = $2`
var reply []*PostgreColumn var reply []*PostgreColumn
err := m.conn.QueryRowsPartial(&reply, querySql, table, schema) err := m.conn.QueryRowsPartial(&reply, querySql, table, schema)

Loading…
Cancel
Save