From 305f6226125b50693333a7f98c688ea720f61591 Mon Sep 17 00:00:00 2001 From: Andrew Benton Date: Wed, 20 Sep 2023 21:27:03 -0700 Subject: [PATCH 1/2] docs: clarify nullable override behavior * also remove some dead code --- docs/reference/config.md | 16 ++++++++++++---- internal/core/fqn.go | 9 --------- 2 files changed, 12 insertions(+), 13 deletions(-) delete mode 100644 internal/core/fqn.go diff --git a/docs/reference/config.md b/docs/reference/config.md index 662070b728..ea01738b7d 100644 --- a/docs/reference/config.md +++ b/docs/reference/config.md @@ -240,6 +240,10 @@ Each mapping of the `overrides` collection has the following keys: - `nullable`: - If `true`, use this type when a column is nullable. Defaults to `false`. +Note that a single `db_type` override configuration applies to either nullable or non-nullable +columns, but not both. If you want a single `go_type` to override in both cases, you'll +need to specify two overrides. + When generating code, entries using the `column` key will always have preference over entries using the `db_type` key in order to generate the struct. @@ -434,11 +438,11 @@ With the previous configuration, whenever a struct field is generated from a table column that is called `id`, it will generated as `Identifier`. Also, whenever there is a nullable `timestamp with time zone` column in a -Postgres table, it will be generated as `null.Time`. Note that, the mapping for +Postgres table, it will be generated as `null.Time`. Note that the mapping for global type overrides has a field called `engine` that is absent in the regular type overrides. This field is only used when there are multiple definitions -using multiple engines. Otherwise, the value of the `engine` key will be -defaulted to the engine that is currently being used. +using multiple engines. Otherwise, the value of the `engine` key +defaults to the engine that is currently being used. Currently, type overrides and field renaming, both global and regular, are only fully supported in Go. @@ -567,6 +571,10 @@ Each override document has the following keys: - `nullable`: - If true, use this type when a column is nullable. Defaults to `false`. +Note that a single `db_type` override configuration applies to either nullable or non-nullable +columns, but not both. If you want a single `go_type` to override in both cases, you'll +need to specify two overrides. + For more complicated import paths, the `go_type` can also be an object. ```yaml @@ -599,7 +607,7 @@ overrides: #### Package Level Overrides -Overrides can be configured globally, as demonstrated in the previous sections, or they can be configured on a per-package which +Overrides can be configured globally, as demonstrated in the previous sections, or they can be configured per-package which scopes the override behavior to just a single package: ```yaml diff --git a/internal/core/fqn.go b/internal/core/fqn.go deleted file mode 100644 index ebdcba8c11..0000000000 --- a/internal/core/fqn.go +++ /dev/null @@ -1,9 +0,0 @@ -package core - -// TODO: This is the last struct left over from the old architecture. Figure -// out how to remove it at some point -type FQN struct { - Catalog string - Schema string - Rel string -} From dba5269dcdc5f2ba13a8a1e95399ddf7b48d2858 Mon Sep 17 00:00:00 2001 From: Andrew Benton Date: Thu, 21 Sep 2023 08:48:54 -0700 Subject: [PATCH 2/2] docs: sync config v1 yaml example with list of go options --- docs/reference/config.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/reference/config.md b/docs/reference/config.md index ea01738b7d..1ce09b4038 100644 --- a/docs/reference/config.md +++ b/docs/reference/config.md @@ -457,6 +457,7 @@ packages: queries: "./sql/query/" schema: "./sql/schema/" engine: "postgresql" + emit_db_tags: false emit_prepared_queries: true emit_interface: false emit_exact_table_names: false @@ -476,6 +477,7 @@ packages: output_models_file_name: "models.go" output_querier_file_name: "querier.go" output_copyfrom_file_name: "copyfrom.go" + query_parameter_limit: 1 ``` ### packages