Skip to content

Commit bac1f37

Browse files
committed
Added test for stream_to
1 parent 49deff4 commit bac1f37

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

test/pqxx_test.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,20 @@ void test_stream(pqxx::connection &conn) {
122122
tx.commit();
123123
}
124124

125+
void test_stream_to(pqxx::connection &conn) {
126+
before_each(conn);
127+
128+
pqxx::work tx(conn);
129+
auto stream = pqxx::stream_to::table(tx, {"items"}, {"embedding"});
130+
stream << pgvector::Vector({1, 2, 3});
131+
stream << pgvector::Vector({4, 5, 6});
132+
stream.complete();
133+
pqxx::result res = tx.exec("SELECT embedding FROM items ORDER BY id");
134+
assert(res[0][0].as<std::string>() == "[1,2,3]");
135+
assert(res[1][0].as<std::string>() == "[4,5,6]");
136+
tx.commit();
137+
}
138+
125139
void test_precision(pqxx::connection &conn) {
126140
before_each(conn);
127141

@@ -144,6 +158,7 @@ int main() {
144158
test_sparsevec(conn);
145159
test_sparsevec_nnz(conn);
146160
test_stream(conn);
161+
test_stream_to(conn);
147162
test_precision(conn);
148163

149164
return 0;

0 commit comments

Comments
 (0)