summaryrefslogtreecommitdiff
path: root/libpqpp/unittests
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2016-02-26 20:47:35 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2016-02-26 20:47:35 +0000
commita221fb5615c6f174d5db463f69377c0829f449ab (patch)
tree1cd11bbaa9e8acfff21296ed518d5e0ae0be8413 /libpqpp/unittests
parentReuse prepared statements (diff)
downloadlibdbpp-postgresql-a221fb5615c6f174d5db463f69377c0829f449ab.tar.bz2
libdbpp-postgresql-a221fb5615c6f174d5db463f69377c0829f449ab.tar.xz
libdbpp-postgresql-a221fb5615c6f174d5db463f69377c0829f449ab.zip
Prepare statement upfront during construction
Diffstat (limited to 'libpqpp/unittests')
-rw-r--r--libpqpp/unittests/testpq.cpp10
1 files changed, 9 insertions, 1 deletions
diff --git a/libpqpp/unittests/testpq.cpp b/libpqpp/unittests/testpq.cpp
index 3d8c804..088910d 100644
--- a/libpqpp/unittests/testpq.cpp
+++ b/libpqpp/unittests/testpq.cpp
@@ -267,14 +267,22 @@ BOOST_AUTO_TEST_CASE( statementReuse )
auto ro = DB::MockDatabase::openConnectionTo("pqmock");
auto pqconn = dynamic_cast<PQ::Connection *>(ro);
BOOST_REQUIRE_EQUAL(pqconn->preparedStatements.size(), 0);
+ ro->modify("DELETE FROM test")->execute();
+ BOOST_REQUIRE_EQUAL(pqconn->preparedStatements.size(), 1);
for (int y = 0; y < 4; y += 1) {
auto m1 = ro->modify("INSERT INTO test(id) VALUES(?)");
+ BOOST_REQUIRE_EQUAL(pqconn->preparedStatements.size(), 2);
for (int x = 0; x < 4; x += 1) {
m1->bindParamI(0, x);
m1->execute();
}
}
- BOOST_REQUIRE_EQUAL(pqconn->preparedStatements.size(), 1);
+ BOOST_REQUIRE_EQUAL(pqconn->preparedStatements.size(), 2);
+ auto select = ro->newSelectCommand("SELECT COUNT(id), SUM(id) FROM test");
+ while (select->fetch()) {
+ assertColumnValueHelper(*select, 0, 16);
+ assertColumnValueHelper(*select, 1, 24);
+ }
delete ro;
}