Skip to content

Commit 3a618a5

Browse files
committed
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
1 parent 4b22260 commit 3a618a5

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

docs/howto/overrides.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,15 @@ Each element in the `overrides` list has the following keys:
4949

5050
- `db_type`:
5151
- 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
60+
> [postgresql_type.go](https://github.com/sqlc-dev/sqlc/blob/main/internal/codegen/golang/postgresql_type.go).
5261
- `column`:
5362
- 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.
5463
- `go_type`:

0 commit comments

Comments
 (0)