Versions in this module Expand all Collapse all v0 v0.0.2 May 22, 2015 v0.0.1 May 22, 2015 Changes in this version + const DEFAULT + const NOW + var EnableInterpolation = false + var ErrArgumentMismatch = errors.New("mismatch between ? (placeholders) and arguments") + var ErrInvalidSliceLength = errors.New("length of slice is 0. length must be >= 1") + var ErrInvalidSliceValue = errors.New("trying to interpolate invalid slice value into query") + var ErrInvalidValue = errors.New("trying to interpolate invalid value into query") + var ErrNotFound = errors.New("not found") + var ErrNotUTF8 = errors.New("invalid UTF-8") + var NameMapping = camelCaseToSnakeCase + var Strict = false + func CalculateFieldMap(recordType reflect.Type, columns []string, requireAllColumns bool) ([][]int, error) + func Interpolate(sql string, vals []interface{}) (string, []interface{}, error) + func PrepareHolderFor(record reflect.Value, fieldMap [][]int, holder []interface{}) ([]interface{}, error) + func SQLMapFromFile(filename string) (map[string]string, error) + func SQLMapFromReader(r io.Reader) (map[string]string, error) + func SQLMapFromString(s string) (map[string]string, error) + func SQLSliceFromFile(filename string) ([]string, error) + func SQLSliceFromString(s string) ([]string, error) + func ValuesFor(recordType reflect.Type, record reflect.Value, columns []string) ([]interface{}, error) + type Builder interface + Interpolate func() (string, []interface{}, error) + IsInterpolated func() bool + ToSQL func() (string, []interface{}) + type DeleteBuilder struct + func DeleteFrom(table string) *DeleteBuilder + func NewDeleteBuilder(table string) *DeleteBuilder + func (b *DeleteBuilder) Interpolate() (string, []interface{}, error) + func (b *DeleteBuilder) IsInterpolated() bool + func (b *DeleteBuilder) Limit(limit uint64) *DeleteBuilder + func (b *DeleteBuilder) Offset(offset uint64) *DeleteBuilder + func (b *DeleteBuilder) OrderBy(ord string) *DeleteBuilder + func (b *DeleteBuilder) Scope(sql string, args ...interface{}) *DeleteBuilder + func (b *DeleteBuilder) ScopeMap(mapScope *MapScope, m M) *DeleteBuilder + func (b *DeleteBuilder) SetIsInterpolated(enable bool) *DeleteBuilder + func (b *DeleteBuilder) ToSQL() (string, []interface{}) + func (b *DeleteBuilder) Where(whereSqlOrMap interface{}, args ...interface{}) *DeleteBuilder + type Eq map[string]interface + type Execer interface + Exec func() (*Result, error) + QueryJSON func() ([]byte, error) + QueryObject func(dest interface{}) error + QueryScalar func(destinations ...interface{}) error + QuerySlice func(dest interface{}) error + QueryStruct func(dest interface{}) error + QueryStructs func(dest interface{}) error + type Expression struct + Args []interface{} + Sql string + func Expr(sql string, values ...interface{}) *Expression + func (exp *Expression) WriteRelativeArgs(buf common.BufferWriter, args *[]interface{}, pos *int64) + type InsectBuilder struct + func Insect(table string) *InsectBuilder + func NewInsectBuilder(table string) *InsectBuilder + func (b *InsectBuilder) Blacklist(columns ...string) *InsectBuilder + func (b *InsectBuilder) Columns(columns ...string) *InsectBuilder + func (b *InsectBuilder) Interpolate() (string, []interface{}, error) + func (b *InsectBuilder) IsInterpolated() bool + func (b *InsectBuilder) Record(record interface{}) *InsectBuilder + func (b *InsectBuilder) Returning(columns ...string) *InsectBuilder + func (b *InsectBuilder) SetIsInterpolated(enable bool) *InsectBuilder + func (b *InsectBuilder) ToSQL() (string, []interface{}) + func (b *InsectBuilder) Values(vals ...interface{}) *InsectBuilder + func (b *InsectBuilder) Where(whereSqlOrMap interface{}, args ...interface{}) *InsectBuilder + func (b *InsectBuilder) Whitelist(columns ...string) *InsectBuilder + type InsertBuilder struct + func InsertInto(table string) *InsertBuilder + func NewInsertBuilder(table string) *InsertBuilder + func (b *InsertBuilder) Blacklist(columns ...string) *InsertBuilder + func (b *InsertBuilder) Columns(columns ...string) *InsertBuilder + func (b *InsertBuilder) Interpolate() (string, []interface{}, error) + func (b *InsertBuilder) IsInterpolated() bool + func (b *InsertBuilder) Pair(column string, value interface{}) *InsertBuilder + func (b *InsertBuilder) Record(record interface{}) *InsertBuilder + func (b *InsertBuilder) Returning(columns ...string) *InsertBuilder + func (b *InsertBuilder) SetIsInterpolated(enable bool) *InsertBuilder + func (b *InsertBuilder) ToSQL() (string, []interface{}) + func (b *InsertBuilder) Values(vals ...interface{}) *InsertBuilder + func (b *InsertBuilder) Whitelist(columns ...string) *InsertBuilder + type Interpolator interface + Interpolate func() (string, error) + type JSON json.RawMessage + func NewJSON(any interface{}) (*JSON, error) + func (j *JSON) MarshalJSON() ([]byte, error) + func (j *JSON) Scan(src interface{}) error + func (j *JSON) Unmarshal(v interface{}) error + func (j *JSON) UnmarshalJSON(data []byte) error + func (j JSON) Interpolate() (string, error) + func (j JSON) Value() (driver.Value, error) + type M map[string]interface + type MapScope struct + Fields M + SQL string + func NewScope(sql string, fields M) *MapScope + func (scope *MapScope) ToSQL(table string) (string, []interface{}) + type NullBool struct + func (n *NullBool) MarshalJSON() ([]byte, error) + type NullFloat64 struct + func (n *NullFloat64) MarshalJSON() ([]byte, error) + type NullInt64 struct + func (n *NullInt64) MarshalJSON() ([]byte, error) + type NullString struct + func (n *NullString) MarshalJSON() ([]byte, error) + type NullTime struct + func (n *NullTime) MarshalJSON() ([]byte, error) + type RawBuilder struct + func NewRawBuilder(sql string, args ...interface{}) *RawBuilder + func SQL(sql string, args ...interface{}) *RawBuilder + func (b *RawBuilder) Interpolate() (string, []interface{}, error) + func (b *RawBuilder) IsInterpolated() bool + func (b *RawBuilder) SetIsInterpolated(enable bool) *RawBuilder + func (b *RawBuilder) ToSQL() (string, []interface{}) + type Result struct + LastInsertID int64 + RowsAffected int64 + type SQLDialect interface + WriteIdentifier func(buf common.BufferWriter, column string) + WriteStringLiteral func(buf common.BufferWriter, value string) + var Dialect SQLDialect + type Scope interface + ToSQL func(table string) (string, []interface{}) + type ScopeFunc func(table string) (string, []interface{}) + func (sf ScopeFunc) ToSQL(table string) (string, []interface{}) + type SelectBuilder struct + func NewSelectBuilder(columns ...string) *SelectBuilder + func Select(columns ...string) *SelectBuilder + func (b *SelectBuilder) Distinct() *SelectBuilder + func (b *SelectBuilder) From(from string) *SelectBuilder + func (b *SelectBuilder) GroupBy(group string) *SelectBuilder + func (b *SelectBuilder) Having(whereSqlOrMap interface{}, args ...interface{}) *SelectBuilder + func (b *SelectBuilder) Interpolate() (string, []interface{}, error) + func (b *SelectBuilder) IsInterpolated() bool + func (b *SelectBuilder) Limit(limit uint64) *SelectBuilder + func (b *SelectBuilder) Offset(offset uint64) *SelectBuilder + func (b *SelectBuilder) OrderBy(ord string) *SelectBuilder + func (b *SelectBuilder) Paginate(page, perPage uint64) *SelectBuilder + func (b *SelectBuilder) Scope(sql string, args ...interface{}) *SelectBuilder + func (b *SelectBuilder) ScopeMap(mapScope *MapScope, m M) *SelectBuilder + func (b *SelectBuilder) SetIsInterpolated(enable bool) *SelectBuilder + func (b *SelectBuilder) ToSQL() (string, []interface{}) + func (b *SelectBuilder) Where(whereSqlOrMap interface{}, args ...interface{}) *SelectBuilder + type SelectDocBuilder struct + func NewSelectDocBuilder(columns ...string) *SelectDocBuilder + func SelectDoc(columns ...string) *SelectDocBuilder + func (b *SelectDocBuilder) As(column string, sqlOrBuilder interface{}, a ...interface{}) *SelectDocBuilder + func (b *SelectDocBuilder) Distinct() *SelectDocBuilder + func (b *SelectDocBuilder) From(from string) *SelectDocBuilder + func (b *SelectDocBuilder) GroupBy(group string) *SelectDocBuilder + func (b *SelectDocBuilder) HasMany(column string, sqlOrBuilder interface{}, a ...interface{}) *SelectDocBuilder + func (b *SelectDocBuilder) HasOne(column string, sqlOrBuilder interface{}, a ...interface{}) *SelectDocBuilder + func (b *SelectDocBuilder) Having(whereSqlOrMap interface{}, args ...interface{}) *SelectDocBuilder + func (b *SelectDocBuilder) InnerSQL(sql string, a ...interface{}) *SelectDocBuilder + func (b *SelectDocBuilder) Interpolate() (string, []interface{}, error) + func (b *SelectDocBuilder) IsInterpolated() bool + func (b *SelectDocBuilder) Limit(limit uint64) *SelectDocBuilder + func (b *SelectDocBuilder) Offset(offset uint64) *SelectDocBuilder + func (b *SelectDocBuilder) OrderBy(ord string) *SelectDocBuilder + func (b *SelectDocBuilder) Paginate(page, perPage uint64) *SelectDocBuilder + func (b *SelectDocBuilder) Scope(sql string, args ...interface{}) *SelectDocBuilder + func (b *SelectDocBuilder) ScopeMap(mapScope *MapScope, m M) *SelectDocBuilder + func (b *SelectDocBuilder) SetIsInterpolated(enable bool) *SelectDocBuilder + func (b *SelectDocBuilder) ToSQL() (string, []interface{}) + func (b *SelectDocBuilder) Where(whereSqlOrMap interface{}, args ...interface{}) *SelectDocBuilder + type UnsafeString string + func (u UnsafeString) Value() (driver.Value, error) + type UpdateBuilder struct + func NewUpdateBuilder(table string) *UpdateBuilder + func Update(table string) *UpdateBuilder + func (b *UpdateBuilder) Interpolate() (string, []interface{}, error) + func (b *UpdateBuilder) IsInterpolated() bool + func (b *UpdateBuilder) Limit(limit uint64) *UpdateBuilder + func (b *UpdateBuilder) Offset(offset uint64) *UpdateBuilder + func (b *UpdateBuilder) OrderBy(ord string) *UpdateBuilder + func (b *UpdateBuilder) Returning(columns ...string) *UpdateBuilder + func (b *UpdateBuilder) Scope(sql string, args ...interface{}) *UpdateBuilder + func (b *UpdateBuilder) ScopeMap(mapScope *MapScope, m M) *UpdateBuilder + func (b *UpdateBuilder) Set(column string, value interface{}) *UpdateBuilder + func (b *UpdateBuilder) SetBlacklist(rec interface{}, columns ...string) *UpdateBuilder + func (b *UpdateBuilder) SetIsInterpolated(enable bool) *UpdateBuilder + func (b *UpdateBuilder) SetMap(clauses map[string]interface{}) *UpdateBuilder + func (b *UpdateBuilder) SetWhitelist(rec interface{}, columns ...string) *UpdateBuilder + func (b *UpdateBuilder) ToSQL() (string, []interface{}) + func (b *UpdateBuilder) Where(whereSqlOrMap interface{}, args ...interface{}) *UpdateBuilder + type UpsertBuilder struct + func NewUpsertBuilder(table string) *UpsertBuilder + func Upsert(table string) *UpsertBuilder + func (b *UpsertBuilder) Blacklist(columns ...string) *UpsertBuilder + func (b *UpsertBuilder) Columns(columns ...string) *UpsertBuilder + func (b *UpsertBuilder) Interpolate() (string, []interface{}, error) + func (b *UpsertBuilder) IsInterpolated() bool + func (b *UpsertBuilder) Record(record interface{}) *UpsertBuilder + func (b *UpsertBuilder) Returning(columns ...string) *UpsertBuilder + func (b *UpsertBuilder) SetIsInterpolated(enable bool) *UpsertBuilder + func (b *UpsertBuilder) ToSQL() (string, []interface{}) + func (b *UpsertBuilder) Values(vals ...interface{}) *UpsertBuilder + func (b *UpsertBuilder) Where(whereSqlOrMap interface{}, args ...interface{}) *UpsertBuilder + func (b *UpsertBuilder) Whitelist(columns ...string) *UpsertBuilder