Skip to content

Commit

Permalink
Test stream_to quoting/escaping.
Browse files Browse the repository at this point in the history
  • Loading branch information
jtv committed Feb 12, 2021
1 parent 9059114 commit aecbc5e
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions test/unit/test_stream_to.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -422,9 +422,31 @@ void test_stream_to_factory_with_dynamic_columns()
}


void test_stream_to_quotes_arguments()
{
pqxx::connection conn;
pqxx::work tx{conn};

std::string const table{R"--(pqxx_Stream"'x)--"}, column{R"--(a'"b)--"};

tx.exec0(
"CREATE TEMP TABLE " + tx.quote_name(table) + "(" + tx.quote_name(column) +
" integer)");
auto write{pqxx::stream_to::table(tx, {table}, {column})};
write.write_values<int>(12);
write.complete();

PQXX_CHECK_EQUAL(
tx.query_value<int>(
"SELECT " + tx.quote_name(column) + " FROM " + tx.quote_name(table)),
12, "Stream wrote wrong value.");
}


PQXX_REGISTER_TEST(test_stream_to);
PQXX_REGISTER_TEST(test_container_stream_to);
PQXX_REGISTER_TEST(test_stream_to__nonnull_optional);
PQXX_REGISTER_TEST(test_stream_to_factory_with_static_columns);
PQXX_REGISTER_TEST(test_stream_to_factory_with_dynamic_columns);
PQXX_REGISTER_TEST(test_stream_to_quotes_arguments);
} // namespace

0 comments on commit aecbc5e

Please sign in to comment.