Versions in this module Expand all Collapse all v1 v1.7.3 Apr 9, 2020 v1.7.2 Apr 9, 2020 Changes in this version + var DBTag = "db" + var DefaultFlavor = MySQL + var ErrInterpolateMissingArgs = errors.New("go-sqlbuilder: not enough args when interpolating") + var ErrInterpolateNotImplemented = errors.New("go-sqlbuilder: interpolation for this flavor is not implemented") + var ErrInterpolateUnsupportedArgs = errors.New("go-sqlbuilder: unsupported args when interpolating") + var FieldOpt = "fieldopt" + var FieldTag = "fieldtag" + func Escape(ident string) string + func EscapeAll(ident ...string) []string + func Flatten(slices interface{}) (flattened []interface{}) + func List(arg interface{}) interface + func Named(name string, arg interface{}) interface + func Raw(expr string) interface + type Args struct + Flavor Flavor + func (args *Args) Add(arg interface{}) string + func (args *Args) Compile(format string, intialValue ...interface{}) (query string, values []interface{}) + func (args *Args) CompileWithFlavor(format string, flavor Flavor, intialValue ...interface{}) (query string, values []interface{}) + type Builder interface + Build func() (sql string, args []interface{}) + BuildWithFlavor func(flavor Flavor, initialArg ...interface{}) (sql string, args []interface{}) + func Build(format string, arg ...interface{}) Builder + func BuildNamed(format string, named map[string]interface{}) Builder + func Buildf(format string, arg ...interface{}) Builder + func WithFlavor(builder Builder, flavor Flavor) Builder + type Cond struct + Args *Args + func (c *Cond) And(andExpr ...string) string + func (c *Cond) Between(field string, lower, upper interface{}) string + func (c *Cond) E(field string, value interface{}) string + func (c *Cond) Equal(field string, value interface{}) string + func (c *Cond) G(field string, value interface{}) string + func (c *Cond) GE(field string, value interface{}) string + func (c *Cond) GreaterEqualThan(field string, value interface{}) string + func (c *Cond) GreaterThan(field string, value interface{}) string + func (c *Cond) In(field string, value ...interface{}) string + func (c *Cond) IsNotNull(field string) string + func (c *Cond) IsNull(field string) string + func (c *Cond) L(field string, value interface{}) string + func (c *Cond) LE(field string, value interface{}) string + func (c *Cond) LessEqualThan(field string, value interface{}) string + func (c *Cond) LessThan(field string, value interface{}) string + func (c *Cond) Like(field string, value interface{}) string + func (c *Cond) NE(field string, value interface{}) string + func (c *Cond) NotBetween(field string, lower, upper interface{}) string + func (c *Cond) NotEqual(field string, value interface{}) string + func (c *Cond) NotIn(field string, value ...interface{}) string + func (c *Cond) NotLike(field string, value interface{}) string + func (c *Cond) Or(orExpr ...string) string + func (c *Cond) Var(value interface{}) string + type CreateTableBuilder struct + func NewCreateTableBuilder() *CreateTableBuilder + func (ctb *CreateTableBuilder) Build() (sql string, args []interface{}) + func (ctb *CreateTableBuilder) BuildWithFlavor(flavor Flavor, initialArg ...interface{}) (sql string, args []interface{}) + func (ctb *CreateTableBuilder) CreateTable(table string) *CreateTableBuilder + func (ctb *CreateTableBuilder) CreateTempTable(table string) *CreateTableBuilder + func (ctb *CreateTableBuilder) Define(def ...string) *CreateTableBuilder + func (ctb *CreateTableBuilder) IfNotExists() *CreateTableBuilder + func (ctb *CreateTableBuilder) Option(opt ...string) *CreateTableBuilder + func (ctb *CreateTableBuilder) SetFlavor(flavor Flavor) (old Flavor) + func (ctb *CreateTableBuilder) String() string + type DeleteBuilder struct + func NewDeleteBuilder() *DeleteBuilder + func (db *DeleteBuilder) Build() (sql string, args []interface{}) + func (db *DeleteBuilder) BuildWithFlavor(flavor Flavor, initialArg ...interface{}) (sql string, args []interface{}) + func (db *DeleteBuilder) DeleteFrom(table string) *DeleteBuilder + func (db *DeleteBuilder) SetFlavor(flavor Flavor) (old Flavor) + func (db *DeleteBuilder) String() string + func (db *DeleteBuilder) Where(andExpr ...string) *DeleteBuilder + type Flavor int + const MySQL + const PostgreSQL + func (f Flavor) Interpolate(sql string, args []interface{}) (string, error) + func (f Flavor) NewCreateTableBuilder() *CreateTableBuilder + func (f Flavor) NewDeleteBuilder() *DeleteBuilder + func (f Flavor) NewInsertBuilder() *InsertBuilder + func (f Flavor) NewSelectBuilder() *SelectBuilder + func (f Flavor) NewUpdateBuilder() *UpdateBuilder + func (f Flavor) Quote(name string) string + func (f Flavor) String() string + type InsertBuilder struct + func NewInsertBuilder() *InsertBuilder + func (ib *InsertBuilder) Build() (sql string, args []interface{}) + func (ib *InsertBuilder) BuildWithFlavor(flavor Flavor, initialArg ...interface{}) (sql string, args []interface{}) + func (ib *InsertBuilder) Cols(col ...string) *InsertBuilder + func (ib *InsertBuilder) InsertIgnoreInto(table string) *InsertBuilder + func (ib *InsertBuilder) InsertInto(table string) *InsertBuilder + func (ib *InsertBuilder) ReplaceInto(table string) *InsertBuilder + func (ib *InsertBuilder) SetFlavor(flavor Flavor) (old Flavor) + func (ib *InsertBuilder) String() string + func (ib *InsertBuilder) Values(value ...interface{}) *InsertBuilder + type JoinOption string + const FullJoin + const FullOuterJoin + const LeftJoin + const LeftOuterJoin + const RightJoin + const RightOuterJoin + type SelectBuilder struct + func NewSelectBuilder() *SelectBuilder + func (sb *SelectBuilder) As(name, alias string) string + func (sb *SelectBuilder) Asc() *SelectBuilder + func (sb *SelectBuilder) Build() (sql string, args []interface{}) + func (sb *SelectBuilder) BuildWithFlavor(flavor Flavor, initialArg ...interface{}) (sql string, args []interface{}) + func (sb *SelectBuilder) BuilderAs(builder Builder, alias string) string + func (sb *SelectBuilder) Desc() *SelectBuilder + func (sb *SelectBuilder) Distinct() *SelectBuilder + func (sb *SelectBuilder) From(table ...string) *SelectBuilder + func (sb *SelectBuilder) GroupBy(col ...string) *SelectBuilder + func (sb *SelectBuilder) Having(andExpr ...string) *SelectBuilder + func (sb *SelectBuilder) Join(table string, onExpr ...string) *SelectBuilder + func (sb *SelectBuilder) JoinWithOption(option JoinOption, table string, onExpr ...string) *SelectBuilder + func (sb *SelectBuilder) Limit(limit int) *SelectBuilder + func (sb *SelectBuilder) Offset(offset int) *SelectBuilder + func (sb *SelectBuilder) OrderBy(col ...string) *SelectBuilder + func (sb *SelectBuilder) Select(col ...string) *SelectBuilder + func (sb *SelectBuilder) SetFlavor(flavor Flavor) (old Flavor) + func (sb *SelectBuilder) String() string + func (sb *SelectBuilder) Where(andExpr ...string) *SelectBuilder + type Struct struct + Flavor Flavor + func NewStruct(structValue interface{}) *Struct + func (s *Struct) Addr(value interface{}) []interface{} + func (s *Struct) AddrForTag(tag string, value interface{}) []interface{} + func (s *Struct) AddrWithCols(cols []string, value interface{}) []interface{} + func (s *Struct) DeleteFrom(table string) *DeleteBuilder + func (s *Struct) For(flavor Flavor) *Struct + func (s *Struct) InsertIgnoreInto(table string, value ...interface{}) *InsertBuilder + func (s *Struct) InsertIgnoreIntoForTag(table string, tag string, value ...interface{}) *InsertBuilder + func (s *Struct) InsertInto(table string, value ...interface{}) *InsertBuilder + func (s *Struct) InsertIntoForTag(table string, tag string, value ...interface{}) *InsertBuilder + func (s *Struct) ReplaceInto(table string, value ...interface{}) *InsertBuilder + func (s *Struct) ReplaceIntoForTag(table string, tag string, value ...interface{}) *InsertBuilder + func (s *Struct) SelectFrom(table string) *SelectBuilder + func (s *Struct) SelectFromForTag(table string, tag string) *SelectBuilder + func (s *Struct) Update(table string, value interface{}) *UpdateBuilder + func (s *Struct) UpdateForTag(table string, tag string, value interface{}) *UpdateBuilder + type UpdateBuilder struct + func NewUpdateBuilder() *UpdateBuilder + func (ub *UpdateBuilder) Add(field string, value interface{}) string + func (ub *UpdateBuilder) Assign(field string, value interface{}) string + func (ub *UpdateBuilder) Build() (sql string, args []interface{}) + func (ub *UpdateBuilder) BuildWithFlavor(flavor Flavor, initialArg ...interface{}) (sql string, args []interface{}) + func (ub *UpdateBuilder) Decr(field string) string + func (ub *UpdateBuilder) Div(field string, value interface{}) string + func (ub *UpdateBuilder) Incr(field string) string + func (ub *UpdateBuilder) Mul(field string, value interface{}) string + func (ub *UpdateBuilder) Set(assignment ...string) *UpdateBuilder + func (ub *UpdateBuilder) SetFlavor(flavor Flavor) (old Flavor) + func (ub *UpdateBuilder) SetMore(assignment ...string) *UpdateBuilder + func (ub *UpdateBuilder) String() string + func (ub *UpdateBuilder) Sub(field string, value interface{}) string + func (ub *UpdateBuilder) Update(table string) *UpdateBuilder + func (ub *UpdateBuilder) Where(andExpr ...string) *UpdateBuilder