Versions in this module Expand all Collapse all v1 v1.0.0 Dec 30, 2022 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 FieldAs = "fieldas" + 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 + func SnakeCaseMapper(field string) string + type Args struct + Flavor Flavor + func (args *Args) Add(arg interface{}) string + func (args *Args) Compile(format string, initialValue ...interface{}) (query string, values []interface{}) + func (args *Args) CompileWithFlavor(format string, flavor Flavor, initialValue ...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 CreateTable(table string) *CreateTableBuilder + 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) PrimaryKey() *CreateTableBuilder + func (ctb *CreateTableBuilder) SQL(sql string) *CreateTableBuilder + func (ctb *CreateTableBuilder) SetFlavor(flavor Flavor) (old Flavor) + func (ctb *CreateTableBuilder) String() string + func (ctb *CreateTableBuilder) Var(arg interface{}) string + type DeleteBuilder struct + func DeleteFrom(table string) *DeleteBuilder + func NewDeleteBuilder() *DeleteBuilder + func (db *DeleteBuilder) Asc() *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) Desc() *DeleteBuilder + func (db *DeleteBuilder) Limit(limit int) *DeleteBuilder + func (db *DeleteBuilder) OrderBy(col ...string) *DeleteBuilder + func (db *DeleteBuilder) SQL(sql string) *DeleteBuilder + func (db *DeleteBuilder) SetFlavor(flavor Flavor) (old Flavor) + func (db *DeleteBuilder) String() string + func (db *DeleteBuilder) Where(andExpr ...string) *DeleteBuilder + type FieldMapperFunc func(name string) string + var DefaultFieldMapper FieldMapperFunc + type Flavor int + const ClickHouse + const MySQL + const PostgreSQL + const SQLServer + const SQLite + 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) NewUnionBuilder() *UnionBuilder + func (f Flavor) NewUpdateBuilder() *UpdateBuilder + func (f Flavor) PrepareInsertIgnore(table string, ib *InsertBuilder) + func (f Flavor) Quote(name string) string + func (f Flavor) String() string + type InsertBuilder struct + func InsertIgnoreInto(table string) *InsertBuilder + func InsertInto(table string) *InsertBuilder + func NewInsertBuilder() *InsertBuilder + func ReplaceInto(table string) *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) SQL(sql string) *InsertBuilder + func (ib *InsertBuilder) SetFlavor(flavor Flavor) (old Flavor) + func (ib *InsertBuilder) String() string + func (ib *InsertBuilder) Values(value ...interface{}) *InsertBuilder + func (ib *InsertBuilder) Var(arg interface{}) string + type JoinOption string + const FullJoin + const FullOuterJoin + const InnerJoin + const LeftJoin + const LeftOuterJoin + const RightJoin + const RightOuterJoin + type SelectBuilder struct + func NewSelectBuilder() *SelectBuilder + func Select(col ...string) *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) ForShare() *SelectBuilder + func (sb *SelectBuilder) ForUpdate() *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) SQL(sql 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(st interface{}) []interface{} + func (s *Struct) AddrForTag(tag string, st interface{}) []interface{} + func (s *Struct) AddrWithCols(cols []string, st interface{}) []interface{} + func (s *Struct) Columns() []string + func (s *Struct) ColumnsForTag(tag string) (cols []string) + 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) (sb *SelectBuilder) + func (s *Struct) Update(table string, value interface{}) *UpdateBuilder + func (s *Struct) UpdateForTag(table string, tag string, value interface{}) *UpdateBuilder + func (s *Struct) Values(st interface{}) []interface{} + func (s *Struct) ValuesForTag(tag string, value interface{}) (values []interface{}) + func (s *Struct) WithFieldMapper(mapper FieldMapperFunc) *Struct + func (s *Struct) WithTag(tag string) *Struct + type UnionBuilder struct + func NewUnionBuilder() *UnionBuilder + func Union(builders ...Builder) *UnionBuilder + func UnionAll(builders ...Builder) *UnionBuilder + func (ub *UnionBuilder) Asc() *UnionBuilder + func (ub *UnionBuilder) Build() (sql string, args []interface{}) + func (ub *UnionBuilder) BuildWithFlavor(flavor Flavor, initialArg ...interface{}) (sql string, args []interface{}) + func (ub *UnionBuilder) Desc() *UnionBuilder + func (ub *UnionBuilder) Limit(limit int) *UnionBuilder + func (ub *UnionBuilder) Offset(offset int) *UnionBuilder + func (ub *UnionBuilder) OrderBy(col ...string) *UnionBuilder + func (ub *UnionBuilder) SQL(sql string) *UnionBuilder + func (ub *UnionBuilder) SetFlavor(flavor Flavor) (old Flavor) + func (ub *UnionBuilder) String() string + func (ub *UnionBuilder) Union(builders ...Builder) *UnionBuilder + func (ub *UnionBuilder) UnionAll(builders ...Builder) *UnionBuilder + func (ub *UnionBuilder) Var(arg interface{}) string + type UpdateBuilder struct + func NewUpdateBuilder() *UpdateBuilder + func Update(table string) *UpdateBuilder + func (ub *UpdateBuilder) Add(field string, value interface{}) string + func (ub *UpdateBuilder) Asc() *UpdateBuilder + 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) Desc() *UpdateBuilder + func (ub *UpdateBuilder) Div(field string, value interface{}) string + func (ub *UpdateBuilder) Incr(field string) string + func (ub *UpdateBuilder) Limit(limit int) *UpdateBuilder + func (ub *UpdateBuilder) Mul(field string, value interface{}) string + func (ub *UpdateBuilder) OrderBy(col ...string) *UpdateBuilder + func (ub *UpdateBuilder) SQL(sql string) *UpdateBuilder + 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