Documentation
¶
Overview ¶
Package sqldimel provides a SQL DML query builder.
Package sqldimel provides a SQL DML query builder.
Index ¶
- type BuildProcessorDefault
- type BuildProcessorNumeric
- type Builder
- func (b *Builder) Add(fieldname string, value interface{}) *Builder
- func (b *Builder) AllowEmptyWhere(value bool)
- func (b *Builder) Exec(db Execer, dmltype DMLType) (res sql.Result, err error)
- func (b *Builder) ExecTx(tx Execer, dmltype DMLType) (res sql.Result, err error)
- func (b *Builder) Output(dmltype DMLType) string
- func (b *Builder) OutputAll(dmltype DMLType) (string, []interface{})
- func (b *Builder) OutputParams(dmltype DMLType) []interface{}
- func (b *Builder) Where(query string, args ...interface{}) *Builder
- type BuilderProcessor
- type DMLType
- type Execer
- type MultiBuilder
- func (mb *MultiBuilder) ClearData()
- func (mb *MultiBuilder) CreateData() *MultiBuilderData
- func (mb *MultiBuilder) DataLen() int
- func (mb *MultiBuilder) Exec(db *sql.DB) (res sql.Result, err error)
- func (mb *MultiBuilder) ExecTx(tx *sql.Tx) (res sql.Result, err error)
- func (mb *MultiBuilder) HasData() bool
- func (mb *MultiBuilder) Output() (string, []interface{})
- type MultiBuilderData
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BuildProcessorDefault ¶
type BuildProcessorDefault struct { }
func NewBuildProcessorDefault ¶
func NewBuildProcessorDefault() *BuildProcessorDefault
BuildProcessorDefault generates parameters using the character "?"
func (*BuildProcessorDefault) BeginParams ¶
func (p *BuildProcessorDefault) BeginParams()
func (*BuildProcessorDefault) NextParam ¶
func (p *BuildProcessorDefault) NextParam(fieldname string) string
type BuildProcessorNumeric ¶
type BuildProcessorNumeric struct {
// contains filtered or unexported fields
}
func NewBuildProcessorNumeric ¶
func NewBuildProcessorNumeric() *BuildProcessorNumeric
BuildProcessorNumeric generates parameters using the character "$" followed by a sequential number starting with 1
func (*BuildProcessorNumeric) BeginParams ¶
func (p *BuildProcessorNumeric) BeginParams()
func (*BuildProcessorNumeric) NextParam ¶
func (p *BuildProcessorNumeric) NextParam(fieldname string) (ret string)
type Builder ¶
type Builder struct {
// contains filtered or unexported fields
}
Builder is the generation class
func NewBuilder ¶
Creates a new builder for the specified table, with a default processor
func NewBuilderProc ¶
func NewBuilderProc(table string, processor BuilderProcessor) *Builder
Creates a new builder for the specified table and processor
func (*Builder) AllowEmptyWhere ¶
Sets if empty Where is allowed (if not, UPDATE / DELETE without where will return blank)
func (*Builder) ExecTx ¶
Execute the current SQL on the transaction (compatibility with previous version)
func (*Builder) Output ¶
Returns the generated SQL. It should be used together with OutputParams to execute on the database. May return blank if "Where" not allowed to be empty
func (*Builder) OutputParams ¶
Returns the parameters to be passed to the database execution
type BuilderProcessor ¶
type BuilderProcessor interface { // Initialize parameter generation BeginParams() // Generates the next field name NextParam(fieldname string) string }
BuilderProcessor generates parameter names compatible with the database
type DMLType ¶
type DMLType int
DMLType is a custom type to identify the type of DML to generate (INSERT, UPDATE or DELETE)
type MultiBuilder ¶ added in v1.1.0
type MultiBuilder struct {
// contains filtered or unexported fields
}
func NewMultiBuilder ¶ added in v1.1.0
func NewMultiBuilder(table string, fields []string) *MultiBuilder
Creates a new multi builder
func NewMultiBuilderProc ¶ added in v1.1.0
func NewMultiBuilderProc(table string, processor BuilderProcessor, fields []string) *MultiBuilder
Creates a new multi builder for the specified table and processor
func (*MultiBuilder) ClearData ¶ added in v1.1.0
func (mb *MultiBuilder) ClearData()
func (*MultiBuilder) CreateData ¶ added in v1.1.0
func (mb *MultiBuilder) CreateData() *MultiBuilderData
func (*MultiBuilder) DataLen ¶ added in v1.1.0
func (mb *MultiBuilder) DataLen() int
func (*MultiBuilder) HasData ¶ added in v1.1.0
func (mb *MultiBuilder) HasData() bool
func (*MultiBuilder) Output ¶ added in v1.1.0
func (mb *MultiBuilder) Output() (string, []interface{})
type MultiBuilderData ¶ added in v1.1.0
type MultiBuilderData struct {
// contains filtered or unexported fields
}
func NewMultiBuilderData ¶ added in v1.1.0
func NewMultiBuilderData() *MultiBuilderData
func (*MultiBuilderData) Add ¶ added in v1.1.0
func (mbd *MultiBuilderData) Add(fieldname string, value interface{}) *MultiBuilderData