Add "like" filter comparator

This commit is contained in:
kolaente 2020-12-19 13:56:55 +01:00
parent b2e4fde63a
commit 90817b6dae
Signed by untrusted user who does not match committer: konrad
GPG key ID: F40E70337AB24C9B
8 changed files with 43 additions and 7 deletions

View file

@ -247,6 +247,17 @@ func getRawTasksForLists(lists []*List, a web.Auth, opts *taskOptions) (tasks []
} else {
filters = append(filters, &builder.Lte{f.field: f.value})
}
case taskFilterComparatorLike:
val, is := f.value.(string)
if !is {
return nil, 0, 0, ErrInvalidTaskFilterValue{Field: f.field, Value: f.value}
}
c := &builder.Like{f.field, "%" + val + "%"}
if opts.filterIncludeNulls {
filters = append(filters, builder.Or(c, &builder.IsNull{f.field}))
} else {
filters = append(filters, c)
}
case taskFilterComparatorInvalid:
// Nothing to do
}