Some checks failed
kotlin / test (push) Has been skipped
python / test (push) Has been skipped
typescript / test (push) Has been skipped
go / build darwin/amd64 (push) Has been cancelled
go / build linux/amd64 (push) Has been cancelled
go / build windows/amd64 (push) Has been cancelled
go / build darwin/arm64 (push) Has been cancelled
go / build linux/arm64 (push) Has been cancelled
go / build windows/arm64 (push) Has been cancelled
go / test (push) Has been cancelled
go / vuln_check (push) Has been cancelled
255 lines
4.6 KiB
Cheetah
255 lines
4.6 KiB
Cheetah
{{define "dbFile"}}
|
|
{{if .BuildTags}}
|
|
//go:build {{.BuildTags}}
|
|
|
|
{{end}}// Code generated by sqlc. DO NOT EDIT.
|
|
{{if not .OmitSqlcVersion}}// versions:
|
|
// sqlc {{.SqlcVersion}}
|
|
{{end}}
|
|
|
|
package {{.Package}}
|
|
|
|
{{ if hasImports .SourceName }}
|
|
import (
|
|
{{range imports .SourceName}}
|
|
{{range .}}{{.}}
|
|
{{end}}
|
|
{{end}}
|
|
)
|
|
{{end}}
|
|
|
|
{{template "dbCode" . }}
|
|
{{end}}
|
|
|
|
{{define "dbCode"}}
|
|
|
|
{{if .SQLDriver.IsPGX }}
|
|
{{- template "dbCodeTemplatePgx" .}}
|
|
{{else}}
|
|
{{- template "dbCodeTemplateStd" .}}
|
|
{{end}}
|
|
|
|
{{end}}
|
|
|
|
{{define "interfaceFile"}}
|
|
{{if .BuildTags}}
|
|
//go:build {{.BuildTags}}
|
|
|
|
{{end}}// Code generated by sqlc. DO NOT EDIT.
|
|
{{if not .OmitSqlcVersion}}// versions:
|
|
// sqlc {{.SqlcVersion}}
|
|
{{end}}
|
|
|
|
package {{.Package}}
|
|
|
|
{{ if hasImports .SourceName }}
|
|
import (
|
|
{{range imports .SourceName}}
|
|
{{range .}}{{.}}
|
|
{{end}}
|
|
{{end}}
|
|
)
|
|
{{end}}
|
|
|
|
{{template "interfaceCode" . }}
|
|
{{end}}
|
|
|
|
{{define "interfaceCode"}}
|
|
{{if .SQLDriver.IsPGX }}
|
|
{{- template "interfaceCodePgx" .}}
|
|
{{else}}
|
|
{{- template "interfaceCodeStd" .}}
|
|
{{end}}
|
|
{{end}}
|
|
|
|
{{define "modelsFile"}}
|
|
{{if .BuildTags}}
|
|
//go:build {{.BuildTags}}
|
|
|
|
{{end}}// Code generated by sqlc. DO NOT EDIT.
|
|
{{if not .OmitSqlcVersion}}// versions:
|
|
// sqlc {{.SqlcVersion}}
|
|
{{end}}
|
|
|
|
package {{.ModelsPackage}}
|
|
|
|
{{ if hasImports .SourceName }}
|
|
import (
|
|
{{range imports .SourceName}}
|
|
{{range .}}{{.}}
|
|
{{end}}
|
|
{{end}}
|
|
)
|
|
{{end}}
|
|
|
|
{{template "modelsCode" . }}
|
|
{{end}}
|
|
|
|
{{define "modelsCode"}}
|
|
{{range .Enums}}
|
|
{{if .Comment}}{{comment .Comment}}{{end}}
|
|
type {{.Name}} string
|
|
|
|
const (
|
|
{{- range .Constants}}
|
|
{{.Name}} {{.Type}} = "{{.Value}}"
|
|
{{- end}}
|
|
)
|
|
|
|
func (e *{{.Name}}) Scan(src any) error {
|
|
switch s := src.(type) {
|
|
case []byte:
|
|
*e = {{.Name}}(s)
|
|
case string:
|
|
*e = {{.Name}}(s)
|
|
default:
|
|
return fmt.Errorf("unsupported scan type for {{.Name}}: %T", src)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
type Null{{.Name}} struct {
|
|
{{.Name}} {{.Name}} {{if .NameTag}}{{$.Q}}{{.NameTag}}{{$.Q}}{{end}}
|
|
Valid bool {{if .ValidTag}}{{$.Q}}{{.ValidTag}}{{$.Q}}{{end}} // Valid is true if {{.Name}} is not NULL
|
|
}
|
|
|
|
// Scan implements the Scanner interface.
|
|
func (ns *Null{{.Name}}) Scan(value any) error {
|
|
if value == nil {
|
|
ns.{{.Name}}, ns.Valid = "", false
|
|
return nil
|
|
}
|
|
ns.Valid = true
|
|
return ns.{{.Name}}.Scan(value)
|
|
}
|
|
|
|
// Value implements the driver Valuer interface.
|
|
func (ns Null{{.Name}}) Value() (driver.Value, error) {
|
|
if !ns.Valid {
|
|
return nil, nil
|
|
}
|
|
return string(ns.{{.Name}}), nil
|
|
}
|
|
|
|
|
|
{{ if $.EmitEnumValidMethod }}
|
|
func (e {{.Name}}) Valid() bool {
|
|
switch e {
|
|
case {{ range $idx, $name := .Constants }}{{ if ne $idx 0 }},{{ "\n" }}{{ end }}{{ .Name }}{{ end }}:
|
|
return true
|
|
}
|
|
return false
|
|
}
|
|
{{ end }}
|
|
|
|
{{ if $.EmitAllEnumValues }}
|
|
func All{{ .Name }}Values() []{{ .Name }} {
|
|
return []{{ .Name }}{ {{ range .Constants}}{{ "\n" }}{{ .Name }},{{ end }}
|
|
}
|
|
}
|
|
{{ end }}
|
|
{{end}}
|
|
|
|
{{range .Structs}}
|
|
{{if .Comment}}{{comment .Comment}}{{end}}
|
|
type {{.Name}} struct { {{- range .Fields}}
|
|
{{- if .Comment}}
|
|
{{comment .Comment}}{{else}}
|
|
{{- end}}
|
|
{{.Name}} {{.Type}} {{if .Tag}}{{$.Q}}{{.Tag}}{{$.Q}}{{end}}
|
|
{{- end}}
|
|
}
|
|
{{end}}
|
|
{{end}}
|
|
|
|
{{define "queryFile"}}
|
|
{{if .BuildTags}}
|
|
//go:build {{.BuildTags}}
|
|
|
|
{{end}}// Code generated by sqlc. DO NOT EDIT.
|
|
{{if not .OmitSqlcVersion}}// versions:
|
|
// sqlc {{.SqlcVersion}}
|
|
{{end}}// source: {{.SourceName}}
|
|
|
|
package {{.Package}}
|
|
|
|
{{ if hasImports .SourceName }}
|
|
import (
|
|
{{range imports .SourceName}}
|
|
{{range .}}{{.}}
|
|
{{end}}
|
|
{{end}}
|
|
)
|
|
{{end}}
|
|
|
|
{{template "queryCode" . }}
|
|
{{end}}
|
|
|
|
{{define "queryCode"}}
|
|
{{if .SQLDriver.IsPGX }}
|
|
{{- template "queryCodePgx" .}}
|
|
{{else}}
|
|
{{- template "queryCodeStd" .}}
|
|
{{end}}
|
|
{{end}}
|
|
|
|
{{define "copyfromFile"}}
|
|
{{if .BuildTags}}
|
|
//go:build {{.BuildTags}}
|
|
|
|
{{end}}// Code generated by sqlc. DO NOT EDIT.
|
|
{{if not .OmitSqlcVersion}}// versions:
|
|
// sqlc {{.SqlcVersion}}
|
|
{{end}}// source: {{.SourceName}}
|
|
|
|
package {{.Package}}
|
|
|
|
{{ if hasImports .SourceName }}
|
|
import (
|
|
{{range imports .SourceName}}
|
|
{{range .}}{{.}}
|
|
{{end}}
|
|
{{end}}
|
|
)
|
|
{{end}}
|
|
|
|
{{template "copyfromCode" . }}
|
|
{{end}}
|
|
|
|
{{define "copyfromCode"}}
|
|
{{if .SQLDriver.IsPGX }}
|
|
{{- template "copyfromCodePgx" .}}
|
|
{{else if .SQLDriver.IsGoSQLDriverMySQL }}
|
|
{{- template "copyfromCodeGoSqlDriver" .}}
|
|
{{end}}
|
|
{{end}}
|
|
|
|
{{define "batchFile"}}
|
|
{{if .BuildTags}}
|
|
//go:build {{.BuildTags}}
|
|
|
|
{{end}}// Code generated by sqlc. DO NOT EDIT.
|
|
{{if not .OmitSqlcVersion}}// versions:
|
|
// sqlc {{.SqlcVersion}}
|
|
{{end}}// source: {{.SourceName}}
|
|
|
|
package {{.Package}}
|
|
|
|
{{ if hasImports .SourceName }}
|
|
import (
|
|
{{range imports .SourceName}}
|
|
{{range .}}{{.}}
|
|
{{end}}
|
|
{{end}}
|
|
)
|
|
{{end}}
|
|
|
|
{{template "batchCode" . }}
|
|
{{end}}
|
|
|
|
{{define "batchCode"}}
|
|
{{if .SQLDriver.IsPGX }}
|
|
{{- template "batchCodePgx" .}}
|
|
{{end}}
|
|
{{end}}
|