42ab71e964
Signed-off-by: Anton Nesterov <anton@demiurg.io>
27 lines
613 B
Go
27 lines
613 B
Go
package filters
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"l12.xyz/dal/utils"
|
|
)
|
|
|
|
type NotBetween struct {
|
|
NotBetween []interface{} `json:"$nbetween"`
|
|
}
|
|
|
|
func (f NotBetween) FromJSON(data interface{}) IFilter {
|
|
return FromJson[NotBetween](data)
|
|
}
|
|
|
|
func (f NotBetween) ToSQLPart(ctx Dialect) (string, Values) {
|
|
if f.NotBetween == nil {
|
|
return "", nil
|
|
}
|
|
name := ctx.GetFieldName()
|
|
values := utils.Map(f.NotBetween, ctx.NormalizeValue)
|
|
placeholders := utils.Map(values, ValueOrPlaceholder)
|
|
condition := fmt.Sprintf("%s AND %s", placeholders[0], placeholders[1])
|
|
return fmt.Sprintf("%s NOT BETWEEN %v", name, condition), values
|
|
}
|