Documentation
¶
Index ¶
- Constants
- Variables
- func EnumReplace(value string) string
- func EnumValueName(value string) string
- func Generate(ctx context.Context, req *plugin.CodeGenRequest) (*plugin.CodeGenResponse, error)
- func JSONTagName(name string, settings *plugin.Settings) string
- func SetCaseStyle(name string, style string) string
- func SetJSONCaseStyle(name string, style string, idUppercase bool) string
- func StructName(name string, settings *plugin.Settings) string
- func TagsToString(tags map[string]string) string
- type Constant
- type Enum
- type Field
- type ImportSpec
- type Query
- type QueryValue
- func (v QueryValue) ColumnNames() []string
- func (v QueryValue) ColumnNamesAsGoSlice() string
- func (v *QueryValue) DefineType() string
- func (v QueryValue) EmitStruct() bool
- func (v QueryValue) Fields() []Field
- func (v QueryValue) HasSqlcSlices() bool
- func (v QueryValue) IsPointer() bool
- func (v QueryValue) IsStruct() bool
- func (v QueryValue) Pair() string
- func (v QueryValue) Params() string
- func (v *QueryValue) ReturnName() string
- func (v QueryValue) Scan() string
- func (v QueryValue) SlicePair() string
- func (v QueryValue) Type() string
- func (v QueryValue) UniqueFields() []Field
- func (v QueryValue) VariableForField(f Field) string
- type SQLDriver
- type Struct
Constants ¶
View Source
const ( SQLPackagePGXV4 string = "pgx/v4" SQLPackagePGXV5 string = "pgx/v5" SQLPackageStandard string = "database/sql" )
View Source
const ( SQLDriverPGXV4 SQLDriver = "github.com/jackc/pgx/v4" SQLDriverPGXV5 = "github.com/jackc/pgx/v5" SQLDriverLibPQ = "github.com/lib/pq" SQLDriverGoSQLDriverMySQL = "github.com/go-sql-driver/mysql" )
Variables ¶
View Source
var IdentPattern = regexp.MustCompile("[^a-zA-Z0-9_]+")
Functions ¶
func EnumReplace ¶
func EnumValueName ¶
func Generate ¶
func Generate(ctx context.Context, req *plugin.CodeGenRequest) (*plugin.CodeGenResponse, error)
func SetCaseStyle ¶
func TagsToString ¶
Types ¶
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
// Used for :copyfrom
Table *plugin.Identifier
}
A struct used to generate methods and fields on the Queries struct
func (Query) TableIdentifierAsGoSlice ¶
func (Query) TableIdentifierForMySQL ¶
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 SQLDriver
// 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) DefineType ¶
func (v *QueryValue) DefineType() string
func (QueryValue) EmitStruct ¶
func (v QueryValue) EmitStruct() bool
func (QueryValue) Fields ¶
func (v QueryValue) Fields() []Field
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) Params ¶
func (v QueryValue) Params() string
func (*QueryValue) ReturnName ¶
func (v *QueryValue) ReturnName() string
func (QueryValue) Scan ¶
func (v QueryValue) Scan() string
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
Click to show internal directories.
Click to hide internal directories.