Skip to content

Commit ac32049

Browse files
docs: clarify nullable override behavior (#2753)
* docs: clarify nullable override behavior * also remove some dead code * docs: sync config v1 yaml example with list of go options
1 parent 34ed2df commit ac32049

File tree

2 files changed

+14
-13
lines changed

2 files changed

+14
-13
lines changed

docs/reference/config.md

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,10 @@ Each mapping of the `overrides` collection has the following keys:
240240
- `nullable`:
241241
- If `true`, use this type when a column is nullable. Defaults to `false`.
242242

243+
Note that a single `db_type` override configuration applies to either nullable or non-nullable
244+
columns, but not both. If you want a single `go_type` to override in both cases, you'll
245+
need to specify two overrides.
246+
243247
When generating code, entries using the `column` key will always have preference over
244248
entries using the `db_type` key in order to generate the struct.
245249

@@ -434,11 +438,11 @@ With the previous configuration, whenever a struct field is generated from a
434438
table column that is called `id`, it will generated as `Identifier`.
435439

436440
Also, whenever there is a nullable `timestamp with time zone` column in a
437-
Postgres table, it will be generated as `null.Time`. Note that, the mapping for
441+
Postgres table, it will be generated as `null.Time`. Note that the mapping for
438442
global type overrides has a field called `engine` that is absent in the regular
439443
type overrides. This field is only used when there are multiple definitions
440-
using multiple engines. Otherwise, the value of the `engine` key will be
441-
defaulted to the engine that is currently being used.
444+
using multiple engines. Otherwise, the value of the `engine` key
445+
defaults to the engine that is currently being used.
442446

443447
Currently, type overrides and field renaming, both global and regular, are only
444448
fully supported in Go.
@@ -453,6 +457,7 @@ packages:
453457
queries: "./sql/query/"
454458
schema: "./sql/schema/"
455459
engine: "postgresql"
460+
emit_db_tags: false
456461
emit_prepared_queries: true
457462
emit_interface: false
458463
emit_exact_table_names: false
@@ -472,6 +477,7 @@ packages:
472477
output_models_file_name: "models.go"
473478
output_querier_file_name: "querier.go"
474479
output_copyfrom_file_name: "copyfrom.go"
480+
query_parameter_limit: 1
475481
```
476482

477483
### packages
@@ -567,6 +573,10 @@ Each override document has the following keys:
567573
- `nullable`:
568574
- If true, use this type when a column is nullable. Defaults to `false`.
569575

576+
Note that a single `db_type` override configuration applies to either nullable or non-nullable
577+
columns, but not both. If you want a single `go_type` to override in both cases, you'll
578+
need to specify two overrides.
579+
570580
For more complicated import paths, the `go_type` can also be an object.
571581

572582
```yaml
@@ -599,7 +609,7 @@ overrides:
599609

600610
#### Package Level Overrides
601611

602-
Overrides can be configured globally, as demonstrated in the previous sections, or they can be configured on a per-package which
612+
Overrides can be configured globally, as demonstrated in the previous sections, or they can be configured per-package which
603613
scopes the override behavior to just a single package:
604614

605615
```yaml

internal/core/fqn.go

Lines changed: 0 additions & 9 deletions
This file was deleted.

0 commit comments

Comments
 (0)