Error in RegisterAddTaskToFilterViewCron when running on PostgreSQL Database #290

Closed
opened 2025-11-01 20:52:58 -05:00 by GiteaMirror · 2 comments
Owner

Originally created by @jnicolson on GitHub (Sep 23, 2024).

Description

Hi,

In commit https://github.com/go-vikunja/vikunja/commit/bc52da4029170bfd10cddea28cf5c6983969cb42 , the SQL at https://github.com/go-vikunja/vikunja/blob/cda0848b2adb2490639ee6055823f81d94be48f4/pkg/models/saved_filters.go#L364 has caused an error when running on PostgreSQL databases (unsure if other databases also have errors).

pq: operator does not exist: json ~~ unknown

This seems to be caused by the datatype being set to JSON https://github.com/go-vikunja/vikunja/blob/cda0848b2adb2490639ee6055823f81d94be48f4/pkg/models/saved_filters.go#L39 which makes Postgres treat queries against the column as JSON queries.

I found three potential resolutions:

  1. Alter filters column in saved_filters table to varchar
  2. Cast to text before the LIKE (i.e. filters::text LIKE '%_date%')
  3. Extract the specific column from the json (i.e. filters->>'filter' LIKE '%_date%')

Options 2 and 3 are postgres specific and i'm unsure if there's any downsides to converting it to varchar - I didn't see any issues after manually altering the column datatype but I don't know xorm well enough to know having the xorm datatype as JSON is required for some other xorm reason.

Vikunja Version

0.24.3

Browser and version

No response

Can you reproduce the bug on the Vikunja demo site?

Please select

Screenshots

No response

Originally created by @jnicolson on GitHub (Sep 23, 2024). ### Description Hi, In commit https://github.com/go-vikunja/vikunja/commit/bc52da4029170bfd10cddea28cf5c6983969cb42 , the SQL at https://github.com/go-vikunja/vikunja/blob/cda0848b2adb2490639ee6055823f81d94be48f4/pkg/models/saved_filters.go#L364 has caused an error when running on PostgreSQL databases (unsure if other databases also have errors). `pq: operator does not exist: json ~~ unknown` This seems to be caused by the datatype being set to JSON https://github.com/go-vikunja/vikunja/blob/cda0848b2adb2490639ee6055823f81d94be48f4/pkg/models/saved_filters.go#L39 which makes Postgres treat queries against the column as JSON queries. I found three potential resolutions: 1. Alter filters column in saved_filters table to varchar 2. Cast to text before the LIKE (i.e. filters::text LIKE '%_date%') 3. Extract the specific column from the json (i.e. filters->>'filter' LIKE '%_date%') Options 2 and 3 are postgres specific and i'm unsure if there's any downsides to converting it to varchar - I didn't see any issues after manually altering the column datatype but I don't know xorm well enough to know having the xorm datatype as JSON is required for some other xorm reason. ### Vikunja Version 0.24.3 ### Browser and version _No response_ ### Can you reproduce the bug on the Vikunja demo site? Please select ### Screenshots _No response_
GiteaMirror added the bug label 2025-11-01 20:52:58 -05:00
Author
Owner

@eiswurm commented on GitHub (Sep 25, 2024):

same here

@eiswurm commented on GitHub (Sep 25, 2024): same here
Author
Owner

@kolaente commented on GitHub (Sep 29, 2024):

Fixed in https://github.com/go-vikunja/vikunja/commit/ca967782e855452f59fecebdd5dc42d46c3ca674, please check with the next unstable build (should be ready for deployment in ~45min, also on try).

@kolaente commented on GitHub (Sep 29, 2024): Fixed in https://github.com/go-vikunja/vikunja/commit/ca967782e855452f59fecebdd5dc42d46c3ca674, please check with the next unstable build (should be ready for deployment in ~45min, also on [try](https://try.vikunja.io)).
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/vikunja#290