From 28f7b6ea0ffbdda86aa385c8b317f0c77c5b12a1 Mon Sep 17 00:00:00 2001 From: Andrew Kane Date: Mon, 5 Aug 2024 15:08:51 -0700 Subject: [PATCH] Improved pgx test --- pgx_test.go | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/pgx_test.go b/pgx_test.go index eee5a64..815aa62 100644 --- a/pgx_test.go +++ b/pgx_test.go @@ -117,11 +117,23 @@ func TestPgx(t *testing.T) { } var item PgxItem - row := conn.QueryRow(ctx, "SELECT embedding, sparse_embedding FROM pgx_items ORDER BY id LIMIT 1", pgx.QueryResultFormats{pgx.TextFormatCode, pgx.TextFormatCode}) - err = row.Scan(&item.Embedding, &item.SparseEmbedding) + row := conn.QueryRow(ctx, "SELECT embedding, half_embedding, binary_embedding, sparse_embedding FROM pgx_items ORDER BY id DESC LIMIT 1", pgx.QueryResultFormats{pgx.TextFormatCode, pgx.TextFormatCode, pgx.TextFormatCode, pgx.TextFormatCode}) + err = row.Scan(&item.Embedding, &item.HalfEmbedding, &item.BinaryEmbedding, &item.SparseEmbedding) if err != nil { panic(err) } + if !reflect.DeepEqual(item.Embedding.Slice(), []float32{1, 1, 2}) { + t.Error() + } + if !reflect.DeepEqual(item.HalfEmbedding.Slice(), []float32{1, 1, 2}) { + t.Error() + } + if item.BinaryEmbedding != "111" { + t.Error() + } + if !reflect.DeepEqual(item.SparseEmbedding.Slice(), []float32{1, 1, 2}) { + t.Error() + } _, err = conn.CopyFrom( ctx,