Skip to content

Commit ee391e6

Browse files
fix: add override tags to result struct (#1867) (#1887)
* fix: add override tags to result struct (#1867) * Update test output for latest version --------- Co-authored-by: Kyle Conroy <[email protected]>
1 parent 97e7e57 commit ee391e6

File tree

6 files changed

+123
-0
lines changed

6 files changed

+123
-0
lines changed

internal/codegen/golang/result.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,7 @@ func columnsToStruct(req *plugin.CodeGenRequest, name string, columns []goColumn
363363
if req.Settings.Go.EmitJsonTags {
364364
tags["json"] = JSONTagName(tagName, req.Settings)
365365
}
366+
addExtraGoStructTags(tags, req, c.Column)
366367
f := Field{
367368
Name: fieldName,
368369
DBName: colName,

internal/endtoend/testdata/overrides_result_tag/stdlib/go/db.go

Lines changed: 31 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/endtoend/testdata/overrides_result_tag/stdlib/go/models.go

Lines changed: 21 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/endtoend/testdata/overrides_result_tag/stdlib/go/query.sql.go

Lines changed: 38 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
CREATE TABLE public.accounts (
2+
id uuid DEFAULT public.uuid_generate_v4() NOT NULL,
3+
state character varying
4+
);
5+
6+
CREATE TABLE public.users_accounts (
7+
ID2 uuid DEFAULT public.uuid_generate_v4() NOT NULL,
8+
name character varying
9+
);
10+
11+
-- name: FindAccount :one
12+
SELECT
13+
a.*,
14+
ua.name
15+
-- other fields
16+
FROM
17+
accounts a
18+
INNER JOIN users_accounts ua ON a.id = ua.id2
19+
WHERE
20+
a.id = @account_id;
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
version: "2"
2+
sql:
3+
- schema: "query.sql"
4+
queries: "query.sql"
5+
engine: "postgresql"
6+
gen:
7+
go:
8+
package: "querytest"
9+
out: "go"
10+
overrides:
11+
- column: accounts.id
12+
go_struct_tag: sometagtype:"some_value"

0 commit comments

Comments
 (0)