dal/pkg/filters/Like.go

21 lines
398 B
Go
Raw Normal View History

package filters
import "fmt"
type Like struct {
Like interface{} `json:"$like"`
}
2024-08-08 17:26:29 +00:00
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}
}