2
0

Fix scan pointer to pointer to nil slice

https://github.com/jackc/pgx/issues/1263
This commit is contained in:
Jack Christensen
2022-07-30 09:10:50 -05:00
parent 7f382f5190
commit c3258b7f52
2 changed files with 18 additions and 0 deletions
+11
View File
@@ -254,6 +254,17 @@ func TestScanPlanInterface(t *testing.T) {
assert.Error(t, err)
}
// https://github.com/jackc/pgx/issues/1263
func TestMapScanPtrToPtrToSlice(t *testing.T) {
m := pgtype.NewMap()
src := []byte("{foo,bar}")
var v *[]string
plan := m.PlanScan(pgtype.TextArrayOID, pgtype.TextFormatCode, &v)
err := plan.Scan(src, &v)
require.NoError(t, err)
require.Equal(t, []string{"foo", "bar"}, *v)
}
func BenchmarkTypeMapScanInt4IntoBinaryDecoder(b *testing.B) {
m := pgtype.NewMap()
src := []byte{0, 0, 0, 42}