diff --git a/tools/goctl/model/sql/model/postgresqlmodel.go b/tools/goctl/model/sql/model/postgresqlmodel.go index 4d056cc0..8c095700 100644 --- a/tools/goctl/model/sql/model/postgresqlmodel.go +++ b/tools/goctl/model/sql/model/postgresqlmodel.go @@ -72,7 +72,8 @@ from ( t.typname AS type, a.atttypmod AS lengthvar, a.attnotnull AS not_null, - b.description AS comment + b.description AS comment, + (c.relnamespace::regnamespace)::varchar AS schema_name FROM pg_class c, pg_attribute a 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.attrelid = c.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 - left join information_schema.columns AS c on t.relname = c.table_name - and t.field = c.column_name and c.table_schema = $2` + 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 + where c.table_schema = $2` var reply []*PostgreColumn err := m.conn.QueryRowsPartial(&reply, querySql, table, schema)