2
0

Fix JSONBArray to have elements of JSONB

This commit is contained in:
Jack Christensen
2020-09-04 18:41:34 -05:00
parent ec14212d30
commit 79b05217d1
3 changed files with 76 additions and 12 deletions
+36
View File
@@ -0,0 +1,36 @@
package pgtype_test
import (
"testing"
"github.com/jackc/pgtype"
"github.com/jackc/pgtype/testutil"
)
func TestJSONBArrayTranscode(t *testing.T) {
testutil.TestSuccessfulTranscode(t, "jsonb[]", []interface{}{
&pgtype.JSONBArray{
Elements: nil,
Dimensions: nil,
Status: pgtype.Present,
},
&pgtype.JSONBArray{
Elements: []pgtype.JSONB{
{Bytes: []byte(`"foo"`), Status: pgtype.Present},
{Status: pgtype.Null},
},
Dimensions: []pgtype.ArrayDimension{{Length: 2, LowerBound: 1}},
Status: pgtype.Present,
},
&pgtype.JSONBArray{Status: pgtype.Null},
&pgtype.JSONBArray{
Elements: []pgtype.JSONB{
{Bytes: []byte(`"foo"`), Status: pgtype.Present},
{Bytes: []byte("null"), Status: pgtype.Present},
{Bytes: []byte("42"), Status: pgtype.Present},
},
Dimensions: []pgtype.ArrayDimension{{Length: 3, LowerBound: 1}},
Status: pgtype.Present,
},
})
}