diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2016-02-26 20:47:35 +0000 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2016-02-26 20:47:35 +0000 |
commit | 203936297e449f0215641037736cc4d142fd4a60 (patch) | |
tree | e2b8ea54713c563cb545a91f791e929b3e19a704 /libpqpp/unittests | |
parent | Reuse prepared statements (diff) | |
download | libdbpp-postgresql-203936297e449f0215641037736cc4d142fd4a60.tar.bz2 libdbpp-postgresql-203936297e449f0215641037736cc4d142fd4a60.tar.xz libdbpp-postgresql-203936297e449f0215641037736cc4d142fd4a60.zip |
Prepare statement upfront during construction
Diffstat (limited to 'libpqpp/unittests')
-rw-r--r-- | libpqpp/unittests/testpq.cpp | 10 |
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; } |