Skip to content

Commit

Permalink
fix: add override tags to result struct (#1867) (#1887)
Browse files Browse the repository at this point in the history
* fix: add override tags to result struct (#1867)

* Update test output for latest version

---------

Co-authored-by: Kyle Conroy <kyle@conroy.org>
  • Loading branch information
akutschera and kyleconroy authored Jun 7, 2023
1 parent 97e7e57 commit ee391e6
Show file tree
Hide file tree
Showing 6 changed files with 123 additions and 0 deletions.
1 change: 1 addition & 0 deletions internal/codegen/golang/result.go
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,7 @@ func columnsToStruct(req *plugin.CodeGenRequest, name string, columns []goColumn
if req.Settings.Go.EmitJsonTags {
tags["json"] = JSONTagName(tagName, req.Settings)
}
addExtraGoStructTags(tags, req, c.Column)
f := Field{
Name: fieldName,
DBName: colName,
Expand Down
31 changes: 31 additions & 0 deletions internal/endtoend/testdata/overrides_result_tag/stdlib/go/db.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions internal/endtoend/testdata/overrides_result_tag/stdlib/query.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
CREATE TABLE public.accounts (
id uuid DEFAULT public.uuid_generate_v4() NOT NULL,
state character varying
);

CREATE TABLE public.users_accounts (
ID2 uuid DEFAULT public.uuid_generate_v4() NOT NULL,
name character varying
);

-- name: FindAccount :one
SELECT
a.*,
ua.name
-- other fields
FROM
accounts a
INNER JOIN users_accounts ua ON a.id = ua.id2
WHERE
a.id = @account_id;
12 changes: 12 additions & 0 deletions internal/endtoend/testdata/overrides_result_tag/stdlib/sqlc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
version: "2"
sql:
- schema: "query.sql"
queries: "query.sql"
engine: "postgresql"
gen:
go:
package: "querytest"
out: "go"
overrides:
- column: accounts.id
go_struct_tag: sometagtype:"some_value"

0 comments on commit ee391e6

Please sign in to comment.