Skip to content

Commit

Permalink
sql/postgres: stub attnum column (#3303)
Browse files Browse the repository at this point in the history
  • Loading branch information
a8m authored Jan 9, 2025
1 parent 7414e31 commit af1adb5
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 79 deletions.
3 changes: 2 additions & 1 deletion sql/postgres/crdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,8 @@ SELECT
col_description(t3.oid, "ordinal_position") AS comment,
t4.typtype,
t4.typelem,
t4.oid
t4.oid,
a.attnum
FROM
"information_schema"."columns" AS t1
JOIN pg_catalog.pg_namespace AS t2 ON t2.nspname = t1.table_schema
Expand Down
7 changes: 4 additions & 3 deletions sql/postgres/inspect_oss.go
Original file line number Diff line number Diff line change
Expand Up @@ -288,12 +288,12 @@ func (i *inspect) columns(ctx context.Context, s *schema.Schema) error {
// addColumn scans the current row and adds a new column from it to the scope (table or view).
func (i *inspect) addColumn(s *schema.Schema, rows *sql.Rows) (err error) {
var (
typid, typelem, maxlen, precision, timeprecision, scale, seqstart, seqinc, seqlast sql.NullInt64
typid, typelem, maxlen, precision, timeprecision, scale, seqstart, seqinc, seqlast, attnum sql.NullInt64
table, name, typ, fmtype, nullable, defaults, identity, genidentity, genexpr, charset, collate, comment, typtype, interval sql.NullString
)
if err = rows.Scan(
&table, &name, &typ, &fmtype, &nullable, &defaults, &maxlen, &precision, &timeprecision, &scale, &interval, &charset,
&collate, &identity, &seqstart, &seqinc, &seqlast, &genidentity, &genexpr, &comment, &typtype, &typelem, &typid,
&collate, &identity, &seqstart, &seqinc, &seqlast, &genidentity, &genexpr, &comment, &typtype, &typelem, &typid, &attnum,
); err != nil {
return err
}
Expand Down Expand Up @@ -1556,7 +1556,8 @@ SELECT
col_description(t3.oid, "ordinal_position") AS comment,
t4.typtype,
t4.typelem,
t4.oid
t4.oid,
a.attnum
FROM
"information_schema"."columns" AS t1
JOIN pg_catalog.pg_namespace AS t2 ON t2.nspname = t1.table_schema
Expand Down
Loading

0 comments on commit af1adb5

Please sign in to comment.