diff --git a/appender_test.go b/appender_test.go index 122c5570..9a00e9f7 100644 --- a/appender_test.go +++ b/appender_test.go @@ -453,15 +453,34 @@ func TestAppenderUUID(t *testing.T) { c, con, a := prepareAppender(t, `CREATE TABLE test (id UUID)`) id := UUID(uuid.New()) + otherId := UUID(uuid.New()) require.NoError(t, a.AppendRow(id)) + require.NoError(t, a.AppendRow(otherId)) + require.NoError(t, a.AppendRow((*UUID)(nil))) + require.NoError(t, a.AppendRow(nil)) require.NoError(t, a.Flush()) // Verify results. - row := sql.OpenDB(c).QueryRowContext(context.Background(), `SELECT id FROM test`) + res, err := sql.OpenDB(c).QueryContext(context.Background(), `SELECT id FROM test`) + require.NoError(t, err) - var res UUID - require.NoError(t, row.Scan(&res)) - require.Equal(t, id, res) + i := 0 + for res.Next() { + if i == 0 { + var r UUID + require.NoError(t, res.Scan(&r)) + require.Equal(t, id, r) + } else { + var r *UUID + require.NoError(t, res.Scan(&r)) + if i == 1 { + require.Equal(t, otherId, *r) + } else { + require.Nil(t, r) + } + } + i++ + } cleanupAppender(t, c, con, a) } diff --git a/vector.go b/vector.go index bc195533..5cc22f1b 100644 --- a/vector.go +++ b/vector.go @@ -462,7 +462,7 @@ func (vec *vector) initUUID() { return hugeIntToUUID(hugeInt) } vec.setFn = func(vec *vector, rowIdx C.idx_t, val any) error { - if val == nil { + if val == nil || val == (*UUID)(nil) { vec.setNull(rowIdx) return nil }