Documentation
¶
Index ¶
- Constants
- func BoolSliceArgs(src ...bool) []interface{}
- func CompileQuery(sql string, opts ...CompileQueryOption) (query string, err error)
- func CompliantName(in string) string
- func Int16SliceArgs(src ...int16) []interface{}
- func Int32SliceArgs(src ...int32) []interface{}
- func Int8SliceArgs(src ...int8) []interface{}
- func IntSliceArgs(src ...int) []interface{}
- func NamedUnbindVars(stmt sqlparser.Statement, withAlias bool, arg interface{}) error
- func Placeholders(n int) string
- func StringSliceArgs(src ...string) []interface{}
- func TimeSliceArgs(src ...time.Time) []interface{}
- func TrimExpr(expr sqlparser.Expr, arg interface{}) sqlparser.Expr
- func TrimInsert(insert *sqlparser.Insert, arg interface{}) error
- func TrimUpdate(update *sqlparser.Update, arg interface{}) error
- func TrimWhere(where *sqlparser.Where, arg interface{})
- func Uint16SliceArgs(src ...uint16) []interface{}
- func Uint32SliceArgs(src ...uint32) []interface{}
- func Uint8SliceArgs(src ...uint8) []interface{}
- func UintSliceArgs(src ...uint) []interface{}
- type CompileQueryOption
- type CompileQueryOptionFunc
- type EmptyCompileQueryOption
- type NullDuration
- type NullJson
Constants ¶
const (
TagDb = "db"
)
Variables ¶
This section is empty.
Functions ¶
func BoolSliceArgs ¶ added in v0.0.70
func BoolSliceArgs(src ...bool) []interface{}
func CompileQuery ¶ added in v0.0.69
func CompileQuery(sql string, opts ...CompileQueryOption) (query string, err error)
CompileQuery compiles a unbound query (using the '?' bind var) into an NamedQuery. WithCompileQueryOptionAliasWithSelect, default true SELECT t.a, b FROM t
TO
select t.a as t_a, b as b
INSERT INTO foo (a,b,c,d) VALUES (?, ?, ?, ?) TO insert into foo(a, b, c, d) values (:a, :b, :c, :d)
func CompliantName ¶ added in v0.0.69
CompliantName returns a compliant id name that can be used for a bind or as var. replace special runes with '_' a.b -> a_b
func Int16SliceArgs ¶ added in v0.0.70
func Int16SliceArgs(src ...int16) []interface{}
func Int32SliceArgs ¶ added in v0.0.70
func Int32SliceArgs(src ...int32) []interface{}
func Int8SliceArgs ¶ added in v0.0.70
func Int8SliceArgs(src ...int8) []interface{}
func IntSliceArgs ¶ added in v0.0.70
func IntSliceArgs(src ...int) []interface{}
func NamedUnbindVars ¶ added in v0.0.69
NamedUnbindVars rewrites unbind vars to named vars referenced in the statement. Ideally, this should be done only once.
func Placeholders ¶ added in v0.0.68
Placeholders behaves like strings.Join([]string{"?",...,"?"}, ",")
func StringSliceArgs ¶ added in v0.0.70
func StringSliceArgs(src ...string) []interface{}
func TimeSliceArgs ¶ added in v0.0.70
func TrimInsert ¶ added in v0.0.69
func TrimUpdate ¶ added in v0.0.69
func Uint16SliceArgs ¶ added in v0.0.70
func Uint16SliceArgs(src ...uint16) []interface{}
func Uint32SliceArgs ¶ added in v0.0.70
func Uint32SliceArgs(src ...uint32) []interface{}
func Uint8SliceArgs ¶ added in v0.0.70
func Uint8SliceArgs(src ...uint8) []interface{}
func UintSliceArgs ¶ added in v0.0.70
func UintSliceArgs(src ...uint) []interface{}
Types ¶
type CompileQueryOption ¶ added in v0.0.69
type CompileQueryOption interface {
// contains filtered or unexported methods
}
A CompileQueryOption sets options.
func WithCompileQueryOptionAliasWithSelect ¶ added in v0.0.69
func WithCompileQueryOptionAliasWithSelect(aliasWithSelect bool) CompileQueryOption
WithCompileQueryOptionAliasWithSelect Generate Alias `SELECT t.a, b` TO `select t.a as t_a, b as b`,
func WithCompileQueryOptionArgument ¶ added in v0.0.69
func WithCompileQueryOptionArgument(arg interface{}) CompileQueryOption
WithCompileQueryOptionArgument keep column if argument by column name is not zero take effect in WHERE|INSERT|UPDATE, ignore if multi rows nil: keep all []string: keep if exist map[string]{{value}} : keep if exist and none zero struct{} tag is `db:"{{col_name}}"`: keep if exist and none zero
`SELECT t.a, b FROM t WHERE first_name= :hehe AND middle_name=? OR last_name=?` TO `select t.a as t_a, b as b from t where first_name = :first_name or last_name = :last_name`,
type CompileQueryOptionFunc ¶ added in v0.0.69
type CompileQueryOptionFunc func(*compileQuery)
CompileQueryOptionFunc wraps a function that modifies compileQuery into an implementation of the CompileQueryOption interface.
type EmptyCompileQueryOption ¶ added in v0.0.69
type EmptyCompileQueryOption struct{}
EmptyCompileQueryOption does not alter the configuration. It can be embedded in another structure to build custom options.
This API is EXPERIMENTAL.
type NullDuration ¶
NullDuration represents an interface that may be null. NullDuration implements the Scanner interface so it can be used as a scan destination, similar to sql.NullString.
func (*NullDuration) Scan ¶
func (nj *NullDuration) Scan(src interface{}) error
Scan implements the sql.Scanner interface.
type NullJson ¶
type NullJson struct { Data interface{} // must be set with a pointer to zero value of expect type Valid bool // Valid is true if Data is not NULL }
NullJson represents an interface that may be null. NullJson implements the Scanner interface so it can be used as a scan destination, similar to sql.NullString. Deprecate, use go-nulljson instead. For more information, see: https://godoc.org/github.com/searKing/golang/tools/cmd/go-nulljson