Skip to content

Commit

Permalink
Added test for stream_to
Browse files Browse the repository at this point in the history
  • Loading branch information
ankane committed Jan 14, 2025
1 parent 49deff4 commit bac1f37
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions test/pqxx_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,20 @@ void test_stream(pqxx::connection &conn) {
tx.commit();
}

void test_stream_to(pqxx::connection &conn) {
before_each(conn);

pqxx::work tx(conn);
auto stream = pqxx::stream_to::table(tx, {"items"}, {"embedding"});
stream << pgvector::Vector({1, 2, 3});
stream << pgvector::Vector({4, 5, 6});
stream.complete();
pqxx::result res = tx.exec("SELECT embedding FROM items ORDER BY id");
assert(res[0][0].as<std::string>() == "[1,2,3]");
assert(res[1][0].as<std::string>() == "[4,5,6]");
tx.commit();
}

void test_precision(pqxx::connection &conn) {
before_each(conn);

Expand All @@ -144,6 +158,7 @@ int main() {
test_sparsevec(conn);
test_sparsevec_nnz(conn);
test_stream(conn);
test_stream_to(conn);
test_precision(conn);

return 0;
Expand Down

0 comments on commit bac1f37

Please sign in to comment.