Documentation
¶
Index ¶
- func EnumReplace(value string) string
- func EnumValueName(value string) string
- func Generate(ctx context.Context, req *plugin.GenerateRequest) (*plugin.GenerateResponse, error)
- func IsReserved(s string) bool
- func JSONTagName(name string, options *opts.Options) string
- func SetCaseStyle(name string, style string) string
- func SetJSONCaseStyle(name string, style string, idUppercase bool) string
- func StructName(name string, options *opts.Options) string
- func TagsToString(tags map[string]string) string
- type Argument
- type BuilderFilter
- type BuilderOrder
- type Constant
- type Enum
- type Field
- type ImportSpec
- type Query
- type QueryBuilder
- type QueryValue
- func (v QueryValue) ColumnNames() []string
- func (v QueryValue) ColumnNamesAsGoSlice() string
- func (v QueryValue) CopyFromMySQLFields() []Fielddeprecated
- func (v *QueryValue) DefineType() string
- func (v QueryValue) EmitStruct() bool
- func (v QueryValue) HasSqlcSlices() bool
- func (v QueryValue) IsPointer() bool
- func (v QueryValue) IsStruct() bool
- func (v QueryValue) Pair() string
- func (v QueryValue) Pairs() []Argument
- func (v QueryValue) Params() string
- func (v *QueryValue) ReturnName() string
- func (v QueryValue) Scan() string
- func (v QueryValue) ScanColumnNamesAsGoSlice() string
- func (v QueryValue) SlicePair() string
- func (v QueryValue) Type() string
- func (v QueryValue) UniqueFields() []Field
- func (v QueryValue) VariableForField(f Field) string
- type Struct
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EnumReplace ¶
EnumReplace removes all non ident symbols (all but letters, numbers and underscore) and returns valid ident name for provided name.
func EnumValueName ¶
EnumValueName removes all non ident symbols (all but letters, numbers and underscore) and converts snake case ident to camel case.
func Generate ¶
func Generate(ctx context.Context, req *plugin.GenerateRequest) (*plugin.GenerateResponse, error)
func IsReserved ¶
func SetCaseStyle ¶
func TagsToString ¶
Types ¶
type BuilderFilter ¶ added in v0.3.0
type BuilderOrder ¶ added in v0.3.0
type Enum ¶
type Field ¶
type Field struct {
Name string // CamelCased name for Go
DBName string // Name as used in the DB
Type string
Tags map[string]string
Comment string
Column *plugin.Column
// EmbedFields contains the embedded fields that require scanning.
EmbedFields []Field
}
func (Field) HasSqlcSlice ¶
type ImportSpec ¶
func (ImportSpec) String ¶
func (s ImportSpec) String() string
type Query ¶
type Query struct {
Cmd string
Comments []string
MethodName string
FieldName string
ConstantName string
SQL string
SourceName string
Ret QueryValue
Arg QueryValue
Builder *QueryBuilder
// Used for :copyfrom
Table *plugin.Identifier
// contains filtered or unexported fields
}
A struct used to generate methods and fields on the Queries struct
func (Query) AndurelGeneric ¶
AndurelGeneric reports whether this query should emit a generic method that scans into a caller-chosen struct via andurel tags.
func (Query) BuilderType ¶ added in v0.3.0
func (Query) BuilderTypeDecl ¶ added in v0.3.0
func (Query) BuilderTypeRef ¶ added in v0.3.0
func (Query) HasBuilder ¶ added in v0.3.0
func (Query) TableIdentifierAsGoSlice ¶
func (Query) TableIdentifierForMySQL ¶
type QueryBuilder ¶ added in v0.3.0
type QueryBuilder struct {
Filters []BuilderFilter
Orders []BuilderOrder
HasWhere bool
Dollar bool
}
type QueryValue ¶
type QueryValue struct {
Emit bool
EmitPointer bool
Name string
DBName string // The name of the field in the database. Only set if Struct==nil.
Struct *Struct
Typ string
SQLDriver opts.SQLDriver
// ModelQualifier prefixes references to model types when the models file
// lives in a different Go package (e.g. "model."). Empty otherwise.
ModelQualifier string
// Column is kept so late in the generation process around to differentiate
// between mysql slices and pg arrays
Column *plugin.Column
}
func (QueryValue) ColumnNames ¶
func (v QueryValue) ColumnNames() []string
func (QueryValue) ColumnNamesAsGoSlice ¶
func (v QueryValue) ColumnNamesAsGoSlice() string
func (QueryValue) CopyFromMySQLFields
deprecated
func (v QueryValue) CopyFromMySQLFields() []Field
Deprecated: This method does not respect the Emit field set on the QueryValue. It's used by the go-sql-driver-mysql/copyfromCopy.tmpl and should not be used other places.
func (*QueryValue) DefineType ¶
func (v *QueryValue) DefineType() string
func (QueryValue) EmitStruct ¶
func (v QueryValue) EmitStruct() bool
func (QueryValue) HasSqlcSlices ¶
func (v QueryValue) HasSqlcSlices() bool
When true, we have to build the arguments to q.db.QueryContext in addition to munging the SQL
func (QueryValue) IsPointer ¶
func (v QueryValue) IsPointer() bool
func (QueryValue) IsStruct ¶
func (v QueryValue) IsStruct() bool
func (QueryValue) Pair ¶
func (v QueryValue) Pair() string
func (QueryValue) Pairs ¶
func (v QueryValue) Pairs() []Argument
Return the argument name and type for query methods. Should only be used in the context of method arguments.
func (QueryValue) Params ¶
func (v QueryValue) Params() string
func (*QueryValue) ReturnName ¶
func (v *QueryValue) ReturnName() string
func (QueryValue) Scan ¶
func (v QueryValue) Scan() string
func (QueryValue) ScanColumnNamesAsGoSlice ¶ added in v0.6.3
func (v QueryValue) ScanColumnNamesAsGoSlice() string
ScanColumnNamesAsGoSlice lists the result columns a generated row scan matches its andurel tags against. It uses the name the query gives the result (the AS alias when there is one), not the underlying table column.
func (QueryValue) SlicePair ¶
func (v QueryValue) SlicePair() string
func (QueryValue) Type ¶
func (v QueryValue) Type() string
func (QueryValue) UniqueFields ¶
func (v QueryValue) UniqueFields() []Field
func (QueryValue) VariableForField ¶
func (v QueryValue) VariableForField(f Field) string
type Struct ¶
type Struct struct {
Table *plugin.Identifier
Name string
Fields []Field
Comment string
// IsModel is true for table structs that live in the models file. When
// the models file is generated into a different Go package, references
// to these types from query files must be qualified.
IsModel bool
}