You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
docs: clarify db_type override must use the canonical parser type name
db_type overrides are matched against the canonical type name the
Postgres parser assigns to a column (e.g. pg_catalog.int4), not the
type name written in the schema (e.g. integer). A mismatch fails
silently: no error, no override applied. Confirmed by building sqlc
and generating with db_type: "integer" (no-op) vs
db_type: "pg_catalog.int4" (applied) against an INTEGER column.
Fixes#2762
Copy file name to clipboardExpand all lines: docs/howto/overrides.md
+9Lines changed: 9 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -49,6 +49,15 @@ Each element in the `overrides` list has the following keys:
49
49
50
50
- `db_type`:
51
51
- A database type to override. Find the full list of supported types in [postgresql_type.go](https://github.com/sqlc-dev/sqlc/blob/main/internal/codegen/golang/postgresql_type.go#L12) or [mysql_type.go](https://github.com/sqlc-dev/sqlc/blob/main/internal/codegen/golang/mysql_type.go#L12). Note that for Postgres you must use pg_catalog-prefixed names where available. `db_type` and `column` are mutually exclusive.
52
+
53
+
> [!WARNING]
54
+
> `db_type` is matched against the canonical type name the Postgres parser
55
+
> assigns to the column, not the type name from your schema. For example,
56
+
> a column declared `INTEGER` has the canonical type `pg_catalog.int4`, so
57
+
> `db_type: "integer"` will silently fail to match (no error, no
58
+
> override) and you must write `db_type: "pg_catalog.int4"` instead. When
59
+
> unsure of a column's canonical type, check the aliases handled in
- A column name to override. The value should be of the form `table.column` but you can also specify `schema.table.column` or `catalog.schema.table.column`. `column` and `db_type` are mutually exclusive.
0 commit comments