Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
fix: requested changes
  • Loading branch information
Hyuga Tsukui committed Oct 6, 2023
commit 25aff982d7eab17e8153292dbbddefb1e32067b3
2 changes: 1 addition & 1 deletion internal/cmd/shim.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ func pluginGoCode(s config.SQLGo) *plugin.GoCode {
EmitPointersForNullTypes: s.EmitPointersForNullTypes,
EmitEnumValidMethod: s.EmitEnumValidMethod,
EmitAllEnumValues: s.EmitAllEnumValues,
BuildTags: s.BuildTags,
JsonTagsCaseStyle: s.JSONTagsCaseStyle,
Package: s.Package,
Out: s.Out,
Expand All @@ -111,6 +110,7 @@ func pluginGoCode(s config.SQLGo) *plugin.GoCode {
InflectionExcludeTableNames: s.InflectionExcludeTableNames,
QueryParameterLimit: s.QueryParameterLimit,
OmitUnusedStructs: s.OmitUnusedStructs,
BuildTags: s.BuildTags,
}
}

Expand Down
4 changes: 2 additions & 2 deletions internal/codegen/golang/gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ type tmplCtx struct {
EmitAllEnumValues bool
UsesCopyFrom bool
UsesBatch bool
BuildTags string
BuildTags string
}

func (t *tmplCtx) OutputQuery(sourceName string) bool {
Expand Down Expand Up @@ -136,7 +136,6 @@ func generate(req *plugin.CodeGenRequest, enums []Enum, structs []Struct, querie
EmitMethodsWithDBArgument: golang.EmitMethodsWithDbArgument,
EmitEnumValidMethod: golang.EmitEnumValidMethod,
EmitAllEnumValues: golang.EmitAllEnumValues,
BuildTags: golang.BuildTags,
UsesCopyFrom: usesCopyFrom(queries),
UsesBatch: usesBatch(queries),
SQLDriver: parseDriver(golang.SqlPackage),
Expand All @@ -145,6 +144,7 @@ func generate(req *plugin.CodeGenRequest, enums []Enum, structs []Struct, querie
Enums: enums,
Structs: structs,
SqlcVersion: req.SqlcVersion,
BuildTags: golang.BuildTags,
}

if tctx.UsesCopyFrom && !tctx.SQLDriver.IsPGX() && golang.SqlDriver != SQLDriverGoSQLDriverMySQL {
Expand Down
6 changes: 0 additions & 6 deletions internal/codegen/golang/templates/template.tmpl
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{{define "dbFile"}}
{{if .BuildTags}}
//go:build {{.BuildTags}}
// +build {{.BuildTags}}

{{end}}// Code generated by sqlc. DO NOT EDIT.
// versions:
Expand Down Expand Up @@ -32,7 +31,6 @@ import (
{{define "interfaceFile"}}
{{if .BuildTags}}
//go:build {{.BuildTags}}
// +build {{.BuildTags}}

{{end}}// Code generated by sqlc. DO NOT EDIT.
// versions:
Expand Down Expand Up @@ -61,7 +59,6 @@ import (
{{define "modelsFile"}}
{{if .BuildTags}}
//go:build {{.BuildTags}}
// +build {{.BuildTags}}

{{end}}// Code generated by sqlc. DO NOT EDIT.
// versions:
Expand Down Expand Up @@ -159,7 +156,6 @@ type {{.Name}} struct { {{- range .Fields}}
{{define "queryFile"}}
{{if .BuildTags}}
//go:build {{.BuildTags}}
// +build {{.BuildTags}}

{{end}}// Code generated by sqlc. DO NOT EDIT.
// versions:
Expand Down Expand Up @@ -189,7 +185,6 @@ import (
{{define "copyfromFile"}}
{{if .BuildTags}}
//go:build {{.BuildTags}}
// +build {{.BuildTags}}

{{end}}// Code generated by sqlc. DO NOT EDIT.
// versions:
Expand Down Expand Up @@ -219,7 +214,6 @@ import (
{{define "batchFile"}}
{{if .BuildTags}}
//go:build {{.BuildTags}}
// +build {{.BuildTags}}

{{end}}// Code generated by sqlc. DO NOT EDIT.
// versions:
Expand Down
2 changes: 1 addition & 1 deletion internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,6 @@ type SQLGo struct {
EmitPointersForNullTypes bool `json:"emit_pointers_for_null_types" yaml:"emit_pointers_for_null_types"`
EmitEnumValidMethod bool `json:"emit_enum_valid_method,omitempty" yaml:"emit_enum_valid_method"`
EmitAllEnumValues bool `json:"emit_all_enum_values,omitempty" yaml:"emit_all_enum_values"`
BuildTags string `json:"build_tags,omitempty" yaml:"build_tags"`
JSONTagsCaseStyle string `json:"json_tags_case_style,omitempty" yaml:"json_tags_case_style"`
Package string `json:"package" yaml:"package"`
Out string `json:"out" yaml:"out"`
Expand All @@ -157,6 +156,7 @@ type SQLGo struct {
InflectionExcludeTableNames []string `json:"inflection_exclude_table_names,omitempty" yaml:"inflection_exclude_table_names"`
QueryParameterLimit *int32 `json:"query_parameter_limit,omitempty" yaml:"query_parameter_limit"`
OmitUnusedStructs bool `json:"omit_unused_structs,omitempty" yaml:"omit_unused_structs"`
BuildTags string `json:"build_tags,omitempty" yaml:"build_tags"`
}

type SQLJSON struct {
Expand Down
2 changes: 1 addition & 1 deletion internal/config/v_one.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ type v1PackageSettings struct {
EmitPointersForNullTypes bool `json:"emit_pointers_for_null_types" yaml:"emit_pointers_for_null_types"`
EmitEnumValidMethod bool `json:"emit_enum_valid_method,omitempty" yaml:"emit_enum_valid_method"`
EmitAllEnumValues bool `json:"emit_all_enum_values,omitempty" yaml:"emit_all_enum_values"`
BuildTags string `json:"build_tags,omitempty" yaml:"build_tags"`
JSONTagsCaseStyle string `json:"json_tags_case_style,omitempty" yaml:"json_tags_case_style"`
SQLPackage string `json:"sql_package" yaml:"sql_package"`
SQLDriver string `json:"sql_driver" yaml:"sql_driver"`
Expand All @@ -54,6 +53,7 @@ type v1PackageSettings struct {
QueryParameterLimit *int32 `json:"query_parameter_limit,omitempty" yaml:"query_parameter_limit"`
OmitUnusedStructs bool `json:"omit_unused_structs,omitempty" yaml:"omit_unused_structs"`
Rules []string `json:"rules" yaml:"rules"`
BuildTags string `json:"build_tags,omitempty" yaml:"build_tags"`
}

func v1ParseConfig(rd io.Reader) (Config, error) {
Expand Down

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.

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

4 changes: 2 additions & 2 deletions internal/endtoend/testdata/codegen_json/gen/codegen.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
"emit_result_struct_pointers": false,
"emit_params_struct_pointers": false,
"emit_methods_with_db_argument": false,
"build_tags": "",
"json_tags_case_style": "",
"package": "",
"out": "",
Expand All @@ -44,7 +43,8 @@
"query_parameter_limit": 1,
"output_batch_file_name": "",
"json_tags_id_uppercase": false,
"omit_unused_structs": false
"omit_unused_structs": false,
"build_tags": ""
},
"json": {
"out": "gen",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@
"query_parameter_limit": 1,
"output_batch_file_name": "",
"json_tags_id_uppercase": false,
"omit_unused_structs": false
"omit_unused_structs": false,
"build_tags": ""
},
"json": {
"out": "",
Expand Down
Loading