Skip to content

Commit

Permalink
remove white space & source
Browse files Browse the repository at this point in the history
  • Loading branch information
kfly8 committed Aug 7, 2024
1 parent 7ae3528 commit 12932b9
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 9 deletions.
2 changes: 0 additions & 2 deletions internal/gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ type tmplCtx struct {
ModelPackage string
Structs []Struct
SqlcVersion string
SourceName string
}

type Struct struct {
Expand Down Expand Up @@ -93,7 +92,6 @@ func generate(req *plugin.GenerateRequest, options *opts.Options, structs []Stru
execute := func(name, templateName string) error {
var b bytes.Buffer
w := bufio.NewWriter(&b)
tctx.SourceName = name
err := tmpl.ExecuteTemplate(w, templateName, &tctx)
w.Flush()
if err != nil {
Expand Down
10 changes: 3 additions & 7 deletions internal/templates/template.tmpl
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
{{define "modelsFile"}}
{{- define "modelsFile" -}}
# Code generated by sqlc. DO NOT EDIT.
# versions:
# sqlc: {{.SqlcVersion}}
# source: {{.SourceName}}

package {{.ModelPackage}};
use strict;
use warnings;
Expand All @@ -15,15 +13,13 @@ use Types::Standard -types;
1;
{{end}}

{{define "modelsCode"}}

{{range .Structs}}
{{- define "modelsCode" -}}
{{- range .Structs -}}
{{if .Comment}}{comment .Comment}{{end}}
use kote {{.Name}} => Dict[ {{- range .Fields}}
{{- if .Comment}}{{comment .Comment}}{{end}}
{{.Name}} => {{.Type}},
{{- end}}
];
{{end}}

{{end}}

0 comments on commit 12932b9

Please sign in to comment.