dal/pkg/filters/Like.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
398 B
Go

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