fix(filters): explicitly search in json when using postgres
All checks were successful
continuous-integration/drone/push Build is passing

Resolves https://github.com/go-vikunja/vikunja/issues/330
Resolves https://community.vikunja.io/t/add-task-to-filter-view-cron-error-fetching-filters-pq-operator-does-not-exist-json-unknown/2831
This commit is contained in:
kolaente 2024-09-29 11:39:44 +02:00
parent 84dbc5fd84
commit ca967782e8
Signed by: konrad
GPG Key ID: F40E70337AB24C9B

@ -360,8 +360,13 @@ func RegisterAddTaskToFilterViewCron() {
defer s.Close()
// Get all filters with a date clause and a manual kanban view
where := "filters LIKE '%_date%'"
if db.GetDialect() == builder.POSTGRES {
where = "filters::jsonb ?| array['due_date', 'start_date', 'end_date']"
}
filters := map[int64]*SavedFilter{}
err := s.Where("filters LIKE '%_date%'").Find(&filters)
err := s.Where(where).Find(&filters)
if err != nil {
log.Errorf("%sError fetching filters: %s", logPrefix, err)
return