Documentation
¶
Index ¶
- func Finalize(placeholder string, expression Expression) (string, []any, error)
- func Map[From any, To any](from []From, mapper func(int, From) To) []To
- func Replace(placeholder string, sql string) (string, int)
- type Caser
- type Compiler
- type Expression
- type ExpressionError
- type Joiner
- type NumberOfArgumentsError
- type Raw
- type Values
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Finalize ¶ added in v1.1.3
func Finalize(placeholder string, expression Expression) (string, []any, error)
Finalize takes a static placeholder like '?' or a positional placeholder containing '%d'. Escaped placeholders ('??') are replaced to '?' when placeholder argument is not '?'.
Types ¶
type Caser ¶ added in v1.1.11
type Caser[T any] struct { Value T Then Expression }
func Case ¶ added in v1.1.11
func Case[T any](value T, then Expression) Caser[T]
type Compiler ¶ added in v0.3.0
type Compiler struct {
Template string
Expressions []Expression
}
func Compile ¶ added in v0.0.10
func Compile(template string, expressions ...Expression) Compiler
Compile takes a template with placeholders into which expressions can be compiled. Escape '?' by using '??'.
type Expression ¶
func If ¶
func If(condition bool, then Expression) Expression
func IfElse ¶ added in v0.0.4
func IfElse(condition bool, then, els Expression) Expression
func Switch ¶ added in v1.1.11
func Switch[T comparable](value T, cases ...Caser[T]) Expression
type ExpressionError ¶ added in v0.0.11
type ExpressionError struct {
Position int
}
ExpressionError is returned by the Compile Expression, if an expression is nil.
func (ExpressionError) Error ¶ added in v0.0.11
func (e ExpressionError) Error() string
type Joiner ¶ added in v0.3.0
type Joiner struct {
Sep string
Expressions []Expression
}
func Append ¶
func Append(expressions ...Expression) Joiner
func Join ¶
func Join(sep string, expressions ...Expression) Joiner
type NumberOfArgumentsError ¶ added in v0.0.11
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
Click to show internal directories.
Click to hide internal directories.