Generator clean up refactoring.
This commit is contained in:
parent
7de8c1c45e
commit
b3a52ceb31
16 changed files with 372 additions and 476 deletions
|
|
@ -1,6 +1,19 @@
|
|||
package generator
|
||||
|
||||
var SqlBuilderTableTemplate = `package table
|
||||
var autoGenWarningTemplate = `
|
||||
//
|
||||
// Code generated by sqlbuilder DO NOT EDIT.
|
||||
// Generated at {{now}}
|
||||
//
|
||||
// WARNING: Changes to this file may cause incorrect behavior and will be lost
|
||||
// if the code is regenerated
|
||||
//
|
||||
// Licence under ...
|
||||
//
|
||||
|
||||
`
|
||||
|
||||
var sqlBuilderTableTemplate = `package table
|
||||
|
||||
import (
|
||||
"github.com/sub0zero/go-sqlbuilder/sqlbuilder"
|
||||
|
|
@ -27,7 +40,7 @@ func new{{.ToGoStructName}}() *{{.ToGoStructName}} {
|
|||
)
|
||||
|
||||
return &{{.ToGoStructName}}{
|
||||
Table: *sqlbuilder.NewTable("{{.DatabaseInfo.SchemaName}}", "{{.Name}}", {{.ToGoColumnFieldList ", "}}),
|
||||
Table: *sqlbuilder.NewTable("{{.SchemaName}}", "{{.Name}}", {{.ToGoColumnFieldList ", "}}),
|
||||
|
||||
//Columns
|
||||
{{- range .Columns}}
|
||||
|
|
@ -49,7 +62,7 @@ func (a *{{.ToGoStructName}}) AS(alias string) *{{.ToGoStructName}} {
|
|||
|
||||
`
|
||||
|
||||
var DataModelTemplate = `package model
|
||||
var dataModelTemplate = `package model
|
||||
|
||||
{{ if .GetImports }}
|
||||
import (
|
||||
|
|
@ -62,12 +75,12 @@ import (
|
|||
|
||||
type {{.ToGoModelStructName}} struct {
|
||||
{{- range .Columns}}
|
||||
{{.ToGoDMFieldName}} {{.ToGoType}} {{if .IsUnique}}` + "`sql:\"unique\"`" + ` {{end}}
|
||||
{{.ToGoFieldName}} {{.ToGoType}} {{if $.IsUnique .Name}}` + "`sql:\"unique\"`" + ` {{end}}
|
||||
{{- end}}
|
||||
}
|
||||
`
|
||||
|
||||
var EnumModelTemplate = `package model
|
||||
var enumModelTemplate = `package model
|
||||
|
||||
import "errors"
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue