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
* internal/config: use strings.Trim{Prefix,Suffix}
This is equivalent and slightly simpler.
* Makefile: fix vtproto 'go install' command
* internal/codegen/golang: simplify template tag condition
Rather than modeling when .Tag will be empty,
check directly whether .Tag is empty.
This simplifies the template and reduces the number
of places that must be touched when adding new
sources of struct tags.
* internal/codegen/golang: tweak tag formatting
Rather than inserting the colon at tag construction time,
insert it at tag formatting time.
This makes the input look a bit more natural.
This matters more, as we are about to add another,
more distant, place where we insert tags.
* all: add support for custom Go struct tags
This change adds a new type of override: go_struct_tag.
When provided for a field, it adds that struct tag to the generated code.
The provided struct tag is parsed according to the standard
package reflect rules, and its components are updated independently.
This allows struct tag overrides to be compatible with (and optionally
override) autogenerated json and db struct tags.
Fixes#534
* go.mod: bump to Go 1.18
The code uses some 1.18-only features, like strings.Cut and testing.F.
The CI requires Go 1.18.
Since Go 1.18 is now required, reflect that in the go.mod.
Copy file name to clipboardExpand all lines: docs/reference/config.md
+3
Original file line number
Diff line number
Diff line change
@@ -225,6 +225,9 @@ Each override document has the following keys:
225
225
- The PostgreSQL or MySQL type to override. Find the full list of supported types in [postgresql_type.go](https://github.com/kyleconroy/sqlc/blob/main/internal/codegen/golang/postgresql_type.go#L12) or [mysql_type.go](https://github.com/kyleconroy/sqlc/blob/main/internal/codegen/golang/mysql_type.go#L12). Note that for Postgres you must use the pg_catalog prefixed names where available.
226
226
- `go_type`:
227
227
- A fully qualified name to a Go type to use in the generated code.
228
+
- `go_struct_tag`:
229
+
- A reflect-style struct tag to use in the generated code, e.g. `a:"b" x:"y,z"`.
230
+
If you want general json/db tags for all fields, use `emit_db_tags` and/or `emit_json_tags` instead.
228
231
- `nullable`:
229
232
- If true, use this type when a column is nullable. Defaults to `false`.
returnnil, fmt.Errorf("Package override `go_type` specifier %q is not the proper format, expected 'package.type', e.g. 'github.com/segmentio/ksuid.KSUID'", input)
139
140
}
140
141
typename=input[lastSlash+1:]
141
-
ifstrings.HasPrefix(typename, "go-") {
142
-
// a package name beginning with "go-" will give syntax errors in
143
-
// generated code. We should do the right thing and get the actual
144
-
// import name, but in lieu of that, stripping the leading "go-" may get
145
-
// us what we want.
146
-
typename=typename[len("go-"):]
147
-
}
148
-
ifstrings.HasSuffix(typename, "-go") {
149
-
typename=typename[:len(typename)-len("-go")]
150
-
}
142
+
// a package name beginning with "go-" will give syntax errors in
143
+
// generated code. We should do the right thing and get the actual
144
+
// import name, but in lieu of that, stripping the leading "go-" may get
0 commit comments