Documentation
¶
Index ¶
- func ToPositional(placeholder string, expr Expression) (string, []any, error)
- type Expression
- func And(expr ...Expression) Expression
- func Append(expressions ...Expression) Expression
- func Between(ident string, lower, higher any) Expression
- func Cast(value any, as string) Expression
- func Compile(template string, expressions ...Expression) Expression
- func Equals(ident string, value any) Expression
- func Greater(ident string, value any) Expression
- func GreaterOrEquals(ident string, value any) Expression
- func Idents(idents ...string) Expression
- func If(condition bool, then Expression) Expression
- func IfElse(condition bool, then, els Expression) Expression
- func In(ident string, values ...any) Expression
- func IsNotNull(ident string) Expression
- func IsNull(ident string) Expression
- func Join(sep string, expressions ...Expression) Expression
- func Less(ident string, value any) Expression
- func LessOrEquals(ident string, value any) Expression
- func Like(ident string, value any) Expression
- func Not(expr Expression) Expression
- func NotBetween(ident string, lower, higher any) Expression
- func NotEquals(ident string, value any) Expression
- func NotIn(ident string, values ...any) Expression
- func NotLike(ident string, value any) Expression
- func Or(left, right Expression) Expression
- func SQL(sql string, args ...any) Expression
- func Value(a any) Expression
- func Values(a ...any) Expression
- type ExpressionError
- type NumberOfArgumentsError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ToPositional ¶ added in v0.0.11
func ToPositional(placeholder string, expr Expression) (string, []any, error)
Types ¶
type Expression ¶
Expression represents a prepared statement.
func Between ¶ added in v0.0.12
func Between(ident string, lower, higher any) Expression
Between returns a BETWEEN expression.
func Cast ¶ added in v0.0.12
func Cast(value any, as string) Expression
Cast returns a CAST expression.
func Compile ¶ added in v0.0.10
func Compile(template string, expressions ...Expression) Expression
Compile takes a template with placeholders into which expressions can be compiled. You can escape '?' by using '??'.
func Equals ¶ added in v0.0.6
func Equals(ident string, value any) Expression
Equals returns an expression with an '=' sign.
func Greater ¶ added in v0.0.6
func Greater(ident string, value any) Expression
Greater returns an expression with an '>' sign.
func GreaterOrEquals ¶ added in v0.0.6
func GreaterOrEquals(ident string, value any) Expression
GreaterOrEquals returns an expression with an '>=' sign.
func Idents ¶ added in v0.0.10
func Idents(idents ...string) Expression
Idents joins idents with ", " to an expression.
func If ¶
func If(condition bool, then Expression) Expression
If returns an expression based on a condition. If false an empty expression is returned.
func IfElse ¶ added in v0.0.4
func IfElse(condition bool, then, els Expression) Expression
IfElse returns an expression based on a condition.
func In ¶ added in v0.0.10
func In(ident string, values ...any) Expression
In returns a IN expression.
func IsNotNull ¶ added in v0.0.12
func IsNotNull(ident string) Expression
IsNotNull returns a IS NOT NULL expression.
func IsNull ¶ added in v0.0.12
func IsNull(ident string) Expression
IsNull returns a IS NULL expression.
func Join ¶
func Join(sep string, expressions ...Expression) Expression
Join joins expressions by a separator.
func Less ¶ added in v0.0.6
func Less(ident string, value any) Expression
Less returns an expression with an '<' sign.
func LessOrEquals ¶ added in v0.0.6
func LessOrEquals(ident string, value any) Expression
LessOrEquals returns an expression with an '<=' sign.
func Like ¶ added in v0.0.12
func Like(ident string, value any) Expression
Like returns a LIKE expression.
func NotBetween ¶ added in v0.0.12
func NotBetween(ident string, lower, higher any) Expression
NotBetween returns a NOT BETWEEN expression.
func NotEquals ¶ added in v0.0.6
func NotEquals(ident string, value any) Expression
NotEquals returns an expression with an '<>' sign.
func NotIn ¶ added in v0.0.12
func NotIn(ident string, values ...any) Expression
NotIn returns a NOT IN expression.
func NotLike ¶ added in v0.0.12
func NotLike(ident string, value any) Expression
NotLike returns a NOT LIKE expression.
func Value ¶ added in v0.0.10
func Value(a any) Expression
Value returns an expression with a placeholder.
func Values ¶ added in v0.0.3
func Values(a ...any) Expression
Values returns an expression with placeholders.
type ExpressionError ¶ added in v0.0.11
type ExpressionError struct{}
ExpressionError is returned if expressions are nil.
func (ExpressionError) Error ¶ added in v0.0.11
func (e ExpressionError) Error() string
type NumberOfArgumentsError ¶ added in v0.0.11
type NumberOfArgumentsError struct{}
NumberOfArgumentsError is returned if arguments doesn't match the number of placeholders.
func (NumberOfArgumentsError) Error ¶ added in v0.0.11
func (e NumberOfArgumentsError) Error() string