From 6bef7896e93283b838b206f6e10db52e44ce1d8c Mon Sep 17 00:00:00 2001 From: kolaente Date: Wed, 9 Sep 2020 00:17:53 +0200 Subject: [PATCH] Add special case for postgrs json --- pkg/models/saved_filters_test.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) 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) {