-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsqlc.yaml
More file actions
56 lines (56 loc) · 2.52 KB
/
Copy pathsqlc.yaml
File metadata and controls
56 lines (56 loc) · 2.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
version: "2"
sql:
- engine: postgresql
schema: db/migrations
queries: db/queries
gen:
go:
package: sqlc
out: db/sqlc
sql_package: pgx/v5
# Nullable columns become *string / *time.Time instead of pgtype.Text /
# pgtype.Timestamptz. That matches the pointer style graph/model already
# uses (e.g. NTA.Email *string), so the mappers stay one-liners.
emit_pointers_for_null_types: true
# A query returning no rows must yield []T{}, not nil: several db methods
# deliberately return make([]*T, 0) because GraphQL non-null lists would
# otherwise serialise to null.
emit_empty_slices: true
# The GraphQL contract lives on graph/model, not on the scan targets.
emit_json_tags: false
# sqlc singularises table names to derive struct names, which mangles the
# German/acronym ones: table `nta` is read as a Latin plural and becomes
# `Ntum`. NOTE the key here is the name sqlc *computed*, not the table
# name -- `nta: ...` silently does nothing.
rename:
ntum: "NTARow"
overrides:
# Ancodes, durations and percentages are plain `int` throughout
# graph/model. Without these two the generated code is int32 and every
# mapper needs an int() conversion.
- db_type: "pg_catalog.int4"
go_type: "int"
- db_type: "pg_catalog.int4"
nullable: true
go_type:
type: "int"
pointer: true
# emit_pointers_for_null_types does NOT reach timestamptz: with the
# pgx/v5 driver sqlc maps it to pgtype.Timestamptz regardless, nullable
# or not. graph/model uses time.Time / *time.Time throughout, and the
# whole point of the Europe/Berlin session time zone is that a scanned
# time.Time carries time.Local and stays usable as a map key -- see
# TestTimestamptzKeepsLocation. Going through pgtype would mean an
# unwrapping step in every single mapper, i.e. ~40 more places to get
# the location wrong.
#
# NOTE the db_type is "timestamptz", not "pg_catalog.timestamptz" --
# the qualified spelling matches nothing and fails silently, the same
# trap as the `rename` key above.
- db_type: "timestamptz"
go_type: "time.Time"
- db_type: "timestamptz"
nullable: true
go_type:
type: "time.Time"
pointer: true