diff --git a/pkg/models/task_collection_filter.go b/pkg/models/task_collection_filter.go index 4a4dd1ccc..3e5331eb9 100644 --- a/pkg/models/task_collection_filter.go +++ b/pkg/models/task_collection_filter.go @@ -266,6 +266,13 @@ func getNativeValueForTaskField(fieldName string, comparator taskFilterComparato return nil, nil, ErrInvalidTaskField{TaskField: fieldName} } + if realFieldName == "Reminders" { + field, ok = reflect.TypeOf(&TaskReminder{}).Elem().FieldByName("Reminder") + if !ok { + return nil, nil, ErrInvalidTaskField{TaskField: fieldName} + } + } + if comparator == taskFilterComparatorIn { vals := strings.Split(value, ",") valueSlice := []interface{}{} diff --git a/pkg/models/task_collection_test.go b/pkg/models/task_collection_test.go index 5091dfbb7..5a1450762 100644 --- a/pkg/models/task_collection_test.go +++ b/pkg/models/task_collection_test.go @@ -933,7 +933,7 @@ func TestTaskCollection_ReadAll(t *testing.T) { { name: "filtered reminder dates", fields: fields{ - FilterBy: []string{"ReminderDates", "ReminderDates"}, + FilterBy: []string{"reminders", "reminders"}, FilterValue: []string{"2018-10-01T00:00:00+00:00", "2018-12-10T00:00:00+00:00"}, FilterComparator: []string{"greater", "less"}, }, diff --git a/pkg/models/tasks.go b/pkg/models/tasks.go index 5a8a19b93..83a413037 100644 --- a/pkg/models/tasks.go +++ b/pkg/models/tasks.go @@ -338,7 +338,7 @@ func getRawTasksForLists(s *xorm.Session, lists []*List, a web.Auth, opts *taskO var filters = make([]builder.Cond, 0, len(opts.filters)) // To still find tasks with nil values, we exclude 0s when comparing with >/< values. for _, f := range opts.filters { - if f.field == "ReminderDates" { + if f.field == "reminders" { f.field = "reminder" // This is the name in the db filter, err := getFilterCond(f, opts.filterIncludeNulls) if err != nil {