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
Emit pointers for nullable enum columns when emit_pointers_for_null_types is set
Closes#3276. When emit_pointers_for_null_types is true (PostgreSQL with
pgx/v4 or pgx/v5), nullable enum columns are now generated as pointers
(*UserRole) instead of the NullUserRole wrapper struct, matching the
existing behavior for other nullable types.
To preserve the previous behavior when upgrading, set
emit_pointers_for_null_enum_types: false. When explicitly set, this flag
overrides emit_pointers_for_null_types for enums only, so it can also be
used to opt into the pointer treatment for enums without enabling it for
every other null type.
https://claude.ai/code/session_01K2xVtbacEbjbA9ymg6dPtr
Copy file name to clipboardExpand all lines: docs/reference/config.md
+6-2Lines changed: 6 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -158,7 +158,9 @@ The `gen` mapping supports the following keys:
158
158
- `emit_methods_with_db_argument`:
159
159
- If true, generated methods will accept a DBTX argument instead of storing a DBTX on the `*Queries` struct. Defaults to `false`.
160
160
- `emit_pointers_for_null_types`:
161
-
- If true, generated types for nullable columns are emitted as pointers (ie. `*string`) instead of `database/sql` null types (ie. `NullString`). Currently only supported for PostgreSQL if `sql_package` is `pgx/v4` or `pgx/v5`, and for SQLite. Defaults to `false`.
161
+
- If true, generated types for nullable columns are emitted as pointers (ie. `*string`) instead of `database/sql` null types (ie. `NullString`). Currently only supported for PostgreSQL if `sql_package` is `pgx/v4` or `pgx/v5`, and for SQLite. Defaults to `false`. Nullable enum columns also follow this setting unless `emit_pointers_for_null_enum_types` is set.
162
+
- `emit_pointers_for_null_enum_types`:
163
+
- Overrides `emit_pointers_for_null_types` for nullable enum columns only. When `true`, nullable enum columns are emitted as pointers (ie. `*UserRole`). When `false`, nullable enum columns use the generated `NullUserRole` wrapper struct even if `emit_pointers_for_null_types` is true. Set this to `false` to keep the pre-v1.31 behavior when upgrading. Only applies to PostgreSQL with `sql_package` `pgx/v4` or `pgx/v5`.
162
164
- `emit_enum_valid_method`:
163
165
- If true, generate a Valid method on enum types,
164
166
indicating whether a string is a valid enum value.
@@ -441,7 +443,9 @@ Each mapping in the `packages` collection has the following keys:
441
443
- `emit_methods_with_db_argument`:
442
444
- If true, generated methods will accept a DBTX argument instead of storing a DBTX on the `*Queries` struct. Defaults to `false`.
443
445
- `emit_pointers_for_null_types`:
444
-
- If true and `sql_package` is set to `pgx/v4` or `pgx/v5`, generated types for nullable columns are emitted as pointers (ie. `*string`) instead of `database/sql` null types (ie. `NullString`). Defaults to `false`.
446
+
- If true and `sql_package` is set to `pgx/v4` or `pgx/v5`, generated types for nullable columns are emitted as pointers (ie. `*string`) instead of `database/sql` null types (ie. `NullString`). Defaults to `false`. Nullable enum columns also follow this setting unless `emit_pointers_for_null_enum_types` is set.
447
+
- `emit_pointers_for_null_enum_types`:
448
+
- Overrides `emit_pointers_for_null_types` for nullable enum columns only. When `true`, nullable enum columns are emitted as pointers (ie. `*UserRole`). When `false`, nullable enum columns use the generated `NullUserRole` wrapper struct even if `emit_pointers_for_null_types` is true. Set this to `false` to keep the pre-v1.31 behavior when upgrading. Only applies to PostgreSQL with `sql_package` `pgx/v4` or `pgx/v5`.
445
449
- `emit_enum_valid_method`:
446
450
- If true, generate a Valid method on enum types,
447
451
indicating whether a string is a valid enum value.
0 commit comments