Documentation
¶
Index ¶
- func ToPositional(placeholder string, expr Expression) (string, []any, error)
- type Expression
- func And(expr ...any) Expression
- func Append(expressions ...any) Expression
- func Between(expr, lower, higher any) Expression
- func BetweenIdent(ident string, lower, higher any) Expression
- func Cast(expr any, as string) Expression
- func CastIdent(ident string, as string) Expression
- func Equals(left, right any) Expression
- func EqualsIdent(ident string, value any) Expression
- func Greater(left, right any) Expression
- func GreaterIdent(ident string, value any) Expression
- func GreaterOrEquals(left, right any) Expression
- func GreaterOrEqualsIdent(ident string, value any) Expression
- func If(condition bool, then any) Expression
- func IfElse(condition bool, then, els any) Expression
- func In(left, right any) Expression
- func InIdent(ident string, value any) Expression
- func IsNotNull(expr any) Expression
- func IsNotNullIdent(ident string) Expression
- func IsNull(expr any) Expression
- func IsNullIdent(ident string) Expression
- func Join(sep string, expressions ...any) Expression
- func Less(left, right any) Expression
- func LessIdent(ident string, value any) Expression
- func LessOrEquals(left, right any) Expression
- func LessOrEqualsIdent(ident string, value any) Expression
- func Like(left, right any) Expression
- func LikeIdent(ident string, value any) Expression
- func Not(expr any) Expression
- func NotBetween(expr, lower, higher any) Expression
- func NotBetweenIdent(ident string, lower, higher any) Expression
- func NotEquals(left, right any) Expression
- func NotEqualsIdent(ident string, value any) Expression
- func NotIn(left, right any) Expression
- func NotInIdent(ident string, value any) Expression
- func NotLike(left, right any) Expression
- func NotLikeIdent(ident string, value any) Expression
- func Or(left, right any) Expression
- func SQL(sql string, expressions ...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(expr, lower, higher any) Expression
Between returns a BETWEEN expression.
func BetweenIdent ¶ added in v0.0.13
func BetweenIdent(ident string, lower, higher any) Expression
BetweenIdent returns a BETWEEN expression.
func Cast ¶ added in v0.0.12
func Cast(expr any, as string) Expression
Cast returns a CAST expression.
func CastIdent ¶ added in v0.0.13
func CastIdent(ident string, as string) Expression
CastIdent returns a CAST expression.
func Equals ¶ added in v0.0.6
func Equals(left, right any) Expression
Equals returns an expression with an '=' sign.
func EqualsIdent ¶ added in v0.0.13
func EqualsIdent(ident string, value any) Expression
EqualsIdent returns an expression with an '=' sign.
func Greater ¶ added in v0.0.6
func Greater(left, right any) Expression
Greater returns an expression with an '>' sign.
func GreaterIdent ¶ added in v0.0.13
func GreaterIdent(ident string, value any) Expression
GreaterIdent returns an expression with an '>' sign.
func GreaterOrEquals ¶ added in v0.0.6
func GreaterOrEquals(left, right any) Expression
GreaterOrEquals returns an expression with an '>=' sign.
func GreaterOrEqualsIdent ¶ added in v0.0.13
func GreaterOrEqualsIdent(ident string, value any) Expression
GreaterOrEqualsIdent returns an expression with an '>=' sign.
func If ¶
func If(condition bool, then any) 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 any) Expression
IfElse returns an expression based on a condition.
func InIdent ¶ added in v0.0.13
func InIdent(ident string, value any) Expression
InIdent returns a IN expression.
func IsNotNull ¶ added in v0.0.12
func IsNotNull(expr any) Expression
IsNotNull returns a IS NOT NULL expression.
func IsNotNullIdent ¶ added in v0.0.13
func IsNotNullIdent(ident string) Expression
IsNotNullIdent returns a IS NOT NULL expression.
func IsNull ¶ added in v0.0.12
func IsNull(expr any) Expression
IsNull returns a IS NULL expression.
func IsNullIdent ¶ added in v0.0.13
func IsNullIdent(ident string) Expression
IsNullIdent returns a IS NULL expression.
func Join ¶
func Join(sep string, expressions ...any) Expression
Join joins expressions by a separator.
func Less ¶ added in v0.0.6
func Less(left, right any) Expression
Less returns an expression with an '<' sign.
func LessIdent ¶ added in v0.0.13
func LessIdent(ident string, value any) Expression
LessIdent returns an expression with an '<' sign.
func LessOrEquals ¶ added in v0.0.6
func LessOrEquals(left, right any) Expression
LessOrEquals returns an expression with an '<=' sign.
func LessOrEqualsIdent ¶ added in v0.0.13
func LessOrEqualsIdent(ident string, value any) Expression
LessOrEqualsIdent returns an expression with an '<=' sign.
func LikeIdent ¶ added in v0.0.13
func LikeIdent(ident string, value any) Expression
LikeIdent returns a LIKE expression.
func NotBetween ¶ added in v0.0.12
func NotBetween(expr, lower, higher any) Expression
NotBetween returns a NOT BETWEEN expression.
func NotBetweenIdent ¶ added in v0.0.13
func NotBetweenIdent(ident string, lower, higher any) Expression
NotBetweenIdent returns a NOT BETWEEN expression.
func NotEquals ¶ added in v0.0.6
func NotEquals(left, right any) Expression
NotEquals returns an expression with an '<>' sign.
func NotEqualsIdent ¶ added in v0.0.13
func NotEqualsIdent(ident string, value any) Expression
NotEqualsIdent returns an expression with an '<>' sign.
func NotIn ¶ added in v0.0.12
func NotIn(left, right any) Expression
NotIn returns a NOT IN expression.
func NotInIdent ¶ added in v0.0.13
func NotInIdent(ident string, value any) Expression
NotInIdent returns a NOT IN expression.
func NotLike ¶ added in v0.0.12
func NotLike(left, right any) Expression
NotLike returns a NOT LIKE expression.
func NotLikeIdent ¶ added in v0.0.13
func NotLikeIdent(ident string, value any) Expression
NotLikeIdent returns a LIKE expression.
func SQL ¶
func SQL(sql string, expressions ...any) Expression
SQL takes a template with placeholders into which expressions can be compiled. Expression []Expression is compiled to Join(", ", expr...). Expression []any is compiled to (?, ?). Expression [][]any is compiled to (?, ?), (?, ?). Escape '?' by using '??'.
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