Documentation ¶
Index ¶
- Variables
- func CommentToMeta(comment string) (map[string]string, string)
- func FieldJSONName(columnName, commentName string) string
- func FieldName(columnName, commentName string, settings GenerateSettings) string
- func Generate(r Generateable, settings GenerateSettings) (map[string]string, error)
- func HasStarRef(cf nodes.ColumnRef) bool
- func Imports(r Generateable, settings GenerateSettings) func(string) [][]string
- func LowerTitle(s string) string
- func ModelImports(r Generateable, settings GenerateSettings) [][]string
- func ParseCatalog(schema string) (core.Catalog, error)
- func ParseMetadata(t string, commentStyle CommentSyntax) (string, string, error)
- func QueryImports(r Generateable, settings GenerateSettings, filename string) [][]string
- func ReadSQLFiles(path string) ([]string, error)
- func RemoveRollbackStatements(contents string) string
- func StructName(name string, settings GenerateSettings) string
- func UsesArrays(r Generateable, settings GenerateSettings) bool
- func UsesType(r Generateable, typ string, settings GenerateSettings) bool
- func Walk(f Visitor, node nodes.Node)
- type CommentSyntax
- type Engine
- type FileErr
- type GenerateSettings
- type Generateable
- type GoConstant
- type GoEnum
- type GoField
- type GoQuery
- type GoQueryValue
- type GoStruct
- type Override
- type PackageSettings
- type Parameter
- type ParserErr
- type Query
- type QueryCatalog
- type Result
- type Visitor
- type VisitorFunc
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrMissingVersion = errors.New("no version number")
View Source
var ErrNoPackageName = errors.New("missing package name")
View Source
var ErrNoPackagePath = errors.New("missing package path")
View Source
var ErrNoPackages = errors.New("no packages")
View Source
var ErrUnknownVersion = errors.New("invalid version number")
Functions ¶
func FieldJSONName ¶
func FieldName ¶
func FieldName(columnName, commentName string, settings GenerateSettings) string
func Generate ¶
func Generate(r Generateable, settings GenerateSettings) (map[string]string, error)
func HasStarRef ¶
func Imports ¶
func Imports(r Generateable, settings GenerateSettings) func(string) [][]string
func LowerTitle ¶
func ModelImports ¶
func ModelImports(r Generateable, settings GenerateSettings) [][]string
func ParseMetadata ¶
func ParseMetadata(t string, commentStyle CommentSyntax) (string, string, error)
func QueryImports ¶
func QueryImports(r Generateable, settings GenerateSettings, filename string) [][]string
func ReadSQLFiles ¶
func RemoveRollbackStatements ¶
Remove all lines after a rollback comment.
goose: -- +goose Down sql-migrate: -- +migrate Down
func StructName ¶
func StructName(name string, settings GenerateSettings) string
func UsesArrays ¶
func UsesArrays(r Generateable, settings GenerateSettings) bool
func UsesType ¶
func UsesType(r Generateable, typ string, settings GenerateSettings) bool
Types ¶
type CommentSyntax ¶
type CommentSyntax int
const ( CommentSyntaxDash CommentSyntax = iota CommentSyntaxStar // Note: this is the only style supported by the MySQL sqlparser CommentSyntaxHash )
type GenerateSettings ¶
type GenerateSettings struct { Version string `json:"version"` Packages []PackageSettings `json:"packages"` Overrides []Override `json:"overrides,omitempty"` Rename map[string]string `json:"rename,omitempty"` PackageMap map[string]PackageSettings }
func ParseConfig ¶
func ParseConfig(rd io.Reader) (GenerateSettings, error)
func (*GenerateSettings) PopulatePkgMap ¶
func (s *GenerateSettings) PopulatePkgMap() error
type Generateable ¶
type Generateable interface { Structs(settings GenerateSettings) []GoStruct PkgName() string GoQueries(settings GenerateSettings) []GoQuery Enums(settings GenerateSettings) []GoEnum }
type GoConstant ¶
type GoEnum ¶
type GoEnum struct { Name string Comment string Constants []GoConstant }
type GoQuery ¶
type GoQuery struct { Cmd string Comments []string MethodName string FieldName string ConstantName string SQL string SourceName string Ret GoQueryValue Arg GoQueryValue }
A struct used to generate methods and fields on the Queries struct
type GoQueryValue ¶
func (GoQueryValue) EmitStruct ¶
func (v GoQueryValue) EmitStruct() bool
func (GoQueryValue) IsStruct ¶
func (v GoQueryValue) IsStruct() bool
func (GoQueryValue) Pair ¶
func (v GoQueryValue) Pair() string
func (GoQueryValue) Params ¶
func (v GoQueryValue) Params() string
func (GoQueryValue) Scan ¶
func (v GoQueryValue) Scan() string
func (GoQueryValue) Type ¶
func (v GoQueryValue) Type() string
type Override ¶
type Override struct { // name of the golang type to use, e.g. `github.com/segmentio/ksuid.KSUID` GoType string `json:"go_type"` // fully qualified name of the Go type, e.g. `github.com/segmentio/ksuid.KSUID` PostgresType string `json:"postgres_type"` // True if the GoType should override if the maching postgres type is nullable Null bool `json:"null"` // fully qualified name of the column, e.g. `accounts.id` Column string `json:"column"` // contains filtered or unexported fields }
type PackageSettings ¶
type PackageSettings struct { Name string `json:"name"` Engine Engine `json:"engine,omitempty"` Path string `json:"path"` Schema string `json:"schema"` Queries string `json:"queries"` EmitInterface bool `json:"emit_interface"` EmitJSONTags bool `json:"emit_json_tags"` EmitPreparedQueries bool `json:"emit_prepared_queries"` Overrides []Override `json:"overrides"` }
type ParserErr ¶
type ParserErr struct {
Errs []FileErr
}
func NewParserErr ¶
func NewParserErr() *ParserErr
type Query ¶
type Query struct { SQL string Columns []core.Column Params []Parameter Name string Cmd string // TODO: Pick a better name. One of: one, many, exec, execrows Comments []string // XXX: Hack Filename string }
Name and Cmd may be empty Maybe I don't need the SQL string if I have the raw Stmt?
type QueryCatalog ¶
type QueryCatalog struct {
// contains filtered or unexported fields
}
func NewQueryCatalog ¶
func NewQueryCatalog(c core.Catalog, with *nodes.WithClause) QueryCatalog
type Result ¶
type Result struct { Queries []*Query Catalog core.Catalog // contains filtered or unexported fields }
func ParseQueries ¶
func ParseQueries(c core.Catalog, pkg PackageSettings) (*Result, error)
func (Result) Enums ¶
func (r Result) Enums(settings GenerateSettings) []GoEnum
func (Result) GoQueries ¶
func (r Result) GoQueries(settings GenerateSettings) []GoQuery
func (Result) Structs ¶
func (r Result) Structs(settings GenerateSettings) []GoStruct
type VisitorFunc ¶
Click to show internal directories.
Click to hide internal directories.