mirror of https://github.com/jackc/pgx.git
parent
997a16dbc5
commit
43ce317556
5
rows.go
5
rows.go
|
@ -204,10 +204,7 @@ func (rows *connRows) Scan(dest ...interface{}) error {
|
||||||
|
|
||||||
if rows.scanPlans == nil {
|
if rows.scanPlans == nil {
|
||||||
rows.scanPlans = make([]pgtype.ScanPlan, len(values))
|
rows.scanPlans = make([]pgtype.ScanPlan, len(values))
|
||||||
for i, dst := range dest {
|
for i := range dest {
|
||||||
if dst == nil {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
rows.scanPlans[i] = ci.PlanScan(fieldDescriptions[i].DataTypeOID, fieldDescriptions[i].Format, dest[i])
|
rows.scanPlans[i] = ci.PlanScan(fieldDescriptions[i].DataTypeOID, fieldDescriptions[i].Format, dest[i])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -950,3 +950,36 @@ func TestRowDecodeBinary(t *testing.T) {
|
||||||
ensureConnValid(t, conn)
|
ensureConnValid(t, conn)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// https://github.com/jackc/pgx/issues/810
|
||||||
|
func TestRowsScanNilThenScanValue(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
|
||||||
|
testWithAndWithoutPreferSimpleProtocol(t, func(t *testing.T, conn *pgx.Conn) {
|
||||||
|
sql := `select null as a, null as b
|
||||||
|
union
|
||||||
|
select 1, 2
|
||||||
|
order by a nulls first
|
||||||
|
`
|
||||||
|
rows, err := conn.Query(context.Background(), sql)
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
require.True(t, rows.Next())
|
||||||
|
|
||||||
|
err = rows.Scan(nil, nil)
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
require.True(t, rows.Next())
|
||||||
|
|
||||||
|
var a int
|
||||||
|
var b int
|
||||||
|
err = rows.Scan(&a, &b)
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
require.EqualValues(t, 1, a)
|
||||||
|
require.EqualValues(t, 2, b)
|
||||||
|
|
||||||
|
rows.Close()
|
||||||
|
require.NoError(t, rows.Err())
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue