Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 2 additions & 0 deletions internal/codegen/golang/gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ type tmplCtx struct {
EmitAllEnumValues bool
UsesCopyFrom bool
UsesBatch bool
OmitSqlcVersion bool
BuildTags string
}

Expand Down Expand Up @@ -185,6 +186,7 @@ func generate(req *plugin.GenerateRequest, options *opts.Options, enums []Enum,
Structs: structs,
SqlcVersion: req.SqlcVersion,
BuildTags: options.BuildTags,
OmitSqlcVersion: options.OmitSqlcVersion,
}

if tctx.UsesCopyFrom && !tctx.SQLDriver.IsPGX() && options.SqlDriver != SQLDriverGoSQLDriverMySQL {
Expand Down
1 change: 1 addition & 0 deletions internal/codegen/golang/opts/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ type Options struct {
OutputFilesSuffix string `json:"output_files_suffix,omitempty" yaml:"output_files_suffix"`
InflectionExcludeTableNames []string `json:"inflection_exclude_table_names,omitempty" yaml:"inflection_exclude_table_names"`
QueryParameterLimit *int32 `json:"query_parameter_limit,omitempty" yaml:"query_parameter_limit"`
OmitSqlcVersion bool `json:"omit_sqlc_version,omitempty" yaml:"omit_sqlc_version"`
OmitUnusedStructs bool `json:"omit_unused_structs,omitempty" yaml:"omit_unused_structs"`
BuildTags string `json:"build_tags,omitempty" yaml:"build_tags"`
}
Expand Down
21 changes: 12 additions & 9 deletions internal/codegen/golang/templates/template.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
//go:build {{.BuildTags}}

{{end}}// Code generated by sqlc. DO NOT EDIT.
// versions:
{{if not .OmitSqlcVersion}}// versions:
// sqlc {{.SqlcVersion}}
{{end}}

package {{.Package}}

Expand Down Expand Up @@ -33,8 +34,9 @@ import (
//go:build {{.BuildTags}}

{{end}}// Code generated by sqlc. DO NOT EDIT.
// versions:
{{if not .OmitSqlcVersion}}// versions:
// sqlc {{.SqlcVersion}}
{{end}}

package {{.Package}}

Expand All @@ -61,8 +63,9 @@ import (
//go:build {{.BuildTags}}

{{end}}// Code generated by sqlc. DO NOT EDIT.
// versions:
{{if not .OmitSqlcVersion}}// versions:
// sqlc {{.SqlcVersion}}
{{end}}

package {{.Package}}

Expand Down Expand Up @@ -158,9 +161,9 @@ type {{.Name}} struct { {{- range .Fields}}
//go:build {{.BuildTags}}

{{end}}// Code generated by sqlc. DO NOT EDIT.
// versions:
{{if not .OmitSqlcVersion}}// versions:
// sqlc {{.SqlcVersion}}
// source: {{.SourceName}}
{{end}}// source: {{.SourceName}}

package {{.Package}}

Expand All @@ -187,9 +190,9 @@ import (
//go:build {{.BuildTags}}

{{end}}// Code generated by sqlc. DO NOT EDIT.
// versions:
{{if not .OmitSqlcVersion}}// versions:
// sqlc {{.SqlcVersion}}
// source: {{.SourceName}}
{{end}}// source: {{.SourceName}}

package {{.Package}}

Expand All @@ -216,9 +219,9 @@ import (
//go:build {{.BuildTags}}

{{end}}// Code generated by sqlc. DO NOT EDIT.
// versions:
{{if not .OmitSqlcVersion}}// versions:
// sqlc {{.SqlcVersion}}
// source: {{.SourceName}}
{{end}}// source: {{.SourceName}}

package {{.Package}}

Expand Down
2 changes: 2 additions & 0 deletions internal/config/v_one.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ type v1PackageSettings struct {
StrictFunctionChecks bool `json:"strict_function_checks" yaml:"strict_function_checks"`
StrictOrderBy *bool `json:"strict_order_by" yaml:"strict_order_by"`
QueryParameterLimit *int32 `json:"query_parameter_limit,omitempty" yaml:"query_parameter_limit"`
OmitSqlcVersion bool `json:"omit_sqlc_version,omitempty" yaml:"omit_sqlc_version"`
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"`
Expand Down Expand Up @@ -162,6 +163,7 @@ func (c *V1GenerateSettings) Translate() Config {
OutputCopyfromFileName: pkg.OutputCopyFromFileName,
OutputFilesSuffix: pkg.OutputFilesSuffix,
QueryParameterLimit: pkg.QueryParameterLimit,
OmitSqlcVersion: pkg.OmitSqlcVersion,
OmitUnusedStructs: pkg.OmitUnusedStructs,
BuildTags: pkg.BuildTags,
},
Expand Down