2
0

Fix: Text array parsing disambiguates NULL and "NULL".

This solution is a little awkward, but it avoids breaking backwards
compatibility.

fixes #78
This commit is contained in:
Jack Christensen
2020-11-07 07:31:56 -06:00
parent 36a8da55cc
commit 740b3a5115
27 changed files with 58 additions and 34 deletions
+12
View File
@@ -6,8 +6,20 @@ import (
"github.com/jackc/pgtype"
"github.com/jackc/pgtype/testutil"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
// https://github.com/jackc/pgtype/issues/78
func TestTextArrayDecodeTextNull(t *testing.T) {
textArray := &pgtype.TextArray{}
err := textArray.DecodeText(nil, []byte(`{abc,"NULL",NULL,def}`))
require.NoError(t, err)
require.Len(t, textArray.Elements, 4)
assert.Equal(t, pgtype.Present, textArray.Elements[1].Status)
assert.Equal(t, pgtype.Null, textArray.Elements[2].Status)
}
func TestTextArrayTranscode(t *testing.T) {
testutil.TestSuccessfulTranscode(t, "text[]", []interface{}{
&pgtype.TextArray{