diff --git a/pkg/models/saved_filters_test.go b/pkg/models/saved_filters_test.go index 4b8ff17d2..413903048 100644 --- a/pkg/models/saved_filters_test.go +++ b/pkg/models/saved_filters_test.go @@ -21,6 +21,7 @@ import ( "code.vikunja.io/api/pkg/user" "github.com/stretchr/testify/assert" "testing" + "xorm.io/xorm/schemas" ) func TestSavedFilter_getListIDFromFilter(t *testing.T) { @@ -53,12 +54,18 @@ func TestSavedFilter_Create(t *testing.T) { err := sf.Create(u) assert.NoError(t, err) assert.Equal(t, u.ID, sf.OwnerID) - db.AssertDBExists(t, "saved_filters", map[string]interface{}{ + vals := map[string]interface{}{ "title": "test", "description": "Lorem Ipsum dolor sit amet", "filters": "{\"sort_by\":null,\"order_by\":null,\"filter_by\":null,\"filter_value\":null,\"filter_comparator\":null,\"filter_concat\":\"\",\"filter_include_nulls\":false}", "owner_id": 1, - }) + } + // Postgres can't compare json values directly, see https://dba.stackexchange.com/a/106290/210721 + if x.Dialect().URI().DBType == schemas.POSTGRES { + delete(vals, "filters") + vals["filters::jsonb"] = "{\"sort_by\":null,\"order_by\":null,\"filter_by\":null,\"filter_value\":null,\"filter_comparator\":null,\"filter_concat\":\"\",\"filter_include_nulls\":false}::jsonb" + } + db.AssertDBExists(t, "saved_filters", vals) } func TestSavedFilter_ReadOne(t *testing.T) {