2024-08-08 09:09:17 +00:00
|
|
|
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 {
|
2024-08-08 09:09:17 +00:00
|
|
|
return FromJson[Like](data)
|
|
|
|
}
|
|
|
|
|
2024-08-11 19:49:19 +00:00
|
|
|
func (f Like) ToSQLPart(ctx Dialect) string {
|
2024-08-08 09:09:17 +00:00
|
|
|
if f.Like == nil {
|
|
|
|
return ""
|
|
|
|
}
|
|
|
|
name := ctx.GetFieldName()
|
|
|
|
value := ctx.NormalizeValue(f.Like)
|
|
|
|
return fmt.Sprintf("%s LIKE %v ESCAPE '\\'", name, value)
|
|
|
|
}
|