dal/pkg/filters/Glob.go
Anton Nesterov 42ab71e964
[ref] use sfmt arguments i/of values in find expressions
Signed-off-by: Anton Nesterov <anton@demiurg.io>
2024-08-12 20:21:47 +02:00

21 lines
386 B
Go

package filters
import "fmt"
type Glob struct {
Glob interface{} `json:"$glob"`
}
func (f Glob) FromJSON(data interface{}) IFilter {
return FromJson[Glob](data)
}
func (f Glob) ToSQLPart(ctx Dialect) (string, Values) {
if f.Glob == nil {
return "", nil
}
name := ctx.GetFieldName()
value := ctx.NormalizeValue(f.Glob)
return fmt.Sprintf("%s GLOB ?", name), Values{value}
}