24
24
out : " mysql
25
25
```
26
26
27
+ ### sql
28
+
27
29
Each mapping in the `sql` collection has the following keys:
28
30
29
31
- `engine`:
@@ -34,18 +36,14 @@ Each mapping in the `sql` collection has the following keys:
34
36
- Directory of SQL queries or path to single SQL file; or a list of paths.
35
37
- `gen`:
36
38
- A mapping to configure built-in code generators. Supports the following keys:
37
- - `go`:
38
- - Go code generation options
39
- - `kotlin`:
40
- - Kotlin code generation options
41
- - `python`:
42
- - Python code generation options
43
- - `json`:
44
- - JSON output options
45
39
- `strict_function_checks`
46
40
- If true, return an error if a called SQL function does not exist. Defaults to `false`.
47
41
48
- ### go
42
+ ### gen
43
+
44
+ The `gen` mapping supports the following keys:
45
+
46
+ #### go
49
47
50
48
- `package`:
51
49
- The package name to use for the generated code. Defaults to `out` basename.
@@ -90,7 +88,7 @@ Each mapping in the `sql` collection has the following keys:
90
88
- `output_files_suffix`:
91
89
- If specified the suffix will be added to the name of the generated files.
92
90
93
- ### kotlin
91
+ #### kotlin
94
92
95
93
- `package`:
96
94
- The package name to use for the generated code.
@@ -99,7 +97,7 @@ Each mapping in the `sql` collection has the following keys:
99
97
- `emit_exact_table_names`:
100
98
- If true, use the exact table name for generated models. Otherwise, guess a singular form. Defaults to `false`.
101
99
102
- ### python
100
+ #### python
103
101
104
102
- `package`:
105
103
- The package name to use for the generated code.
@@ -114,7 +112,14 @@ Each mapping in the `sql` collection has the following keys:
114
112
- `emit_pydantic_models`:
115
113
- If true, generate classes that inherit from `pydantic.BaseModel`. Otherwise, define classes using the `dataclass` decorator. Defaults to `false`.
116
114
117
- ### json
115
+ #### json
116
+
117
+ - `out`:
118
+ - Output directory for the generated JSON.
119
+ - `filename`:
120
+ - Filename for the generated JSON document. Defaults to `codegen_request.json`.
121
+ - `indent`:
122
+ - Indent string to use in the JSON document. Defaults to ` `.
118
123
119
124
## Version 1
120
125
@@ -143,6 +148,8 @@ packages:
143
148
output_querier_file_name : " querier.go"
144
149
` ` `
145
150
151
+ ### packages
152
+
146
153
Each mapping in the ` packages` collection has the following keys:
147
154
148
155
- `name` :
@@ -194,7 +201,7 @@ Each mapping in the `packages` collection has the following keys:
194
201
- `output_files_suffix` :
195
202
- If specified the suffix will be added to the name of the generated files.
196
203
197
- # # Type Overrides
204
+ # ## overrides
198
205
199
206
The default mapping of PostgreSQL/MySQL types to Go types only uses packages outside
200
207
the standard library when it must.
@@ -235,7 +242,7 @@ overrides:
235
242
pointer: false # or true
236
243
` ` `
237
244
238
- # # Per-Column Type Overrides
245
+ # ### Per-Column Type Overrides
239
246
240
247
Sometimes you would like to override the Go type used in model or query generation for
241
248
a specific field of a table and not on a type basis as described in the previous section.
@@ -252,7 +259,7 @@ overrides:
252
259
go_type: "github.com/segmentio/ksuid.KSUID"
253
260
` ` `
254
261
255
- # # Package Level Overrides
262
+ # ### Package Level Overrides
256
263
257
264
Overrides can be configured globally, as demonstrated in the previous sections, or they can be configured on a per-package which
258
265
scopes the override behavior to just a single package :
@@ -263,7 +270,7 @@ packages:
263
270
- overrides: [...]
264
271
` ` `
265
272
266
- # # Renaming Struct Fields
273
+ # ## rename
267
274
268
275
Struct field names are generated from column names using a simple algorithm :
269
276
split the column name on underscores and capitalize the first letter of each
@@ -275,7 +282,7 @@ spotify_url -> SpotifyUrl
275
282
app_id -> AppID
276
283
```
277
284
278
- If you're not happy with a field's generated name, use the `rename` dictionary
285
+ If you're not happy with a field's generated name, use the `rename` mapping
279
286
to pick a new name. The keys are column names and the values are the struct
280
287
field name to use.
281
288
0 commit comments