summaryrefslogtreecommitdiff
path: root/libpqpp/unittests/testpq.cpp
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2018-04-01 13:52:39 +0100
committerDan Goodliffe <dan@randomdan.homeip.net>2018-04-01 13:52:39 +0100
commit55b8c97ae06dd7902d3dc47eece04890ecaf30bc (patch)
tree0b978c58516dfe1ca74c0ac12807267728b93b85 /libpqpp/unittests/testpq.cpp
parentAdd a test case for a genuine large binary object (the memmapped test binary) (diff)
downloadlibdbpp-postgresql-55b8c97ae06dd7902d3dc47eece04890ecaf30bc.tar.bz2
libdbpp-postgresql-55b8c97ae06dd7902d3dc47eece04890ecaf30bc.tar.xz
libdbpp-postgresql-55b8c97ae06dd7902d3dc47eece04890ecaf30bc.zip
Transactionless cursor selects
Remove the need to open a transaction for a cursor select by specifying them as WITH HOLD. Also add NO SCROLL as it's a feature we don't actually use. Updates tests with loops to ensure we haven't broken the ability to re-use / re-create statements.
Diffstat (limited to 'libpqpp/unittests/testpq.cpp')
-rw-r--r--libpqpp/unittests/testpq.cpp13
1 files changed, 9 insertions, 4 deletions
diff --git a/libpqpp/unittests/testpq.cpp b/libpqpp/unittests/testpq.cpp
index 476c3a2..cfe7b11 100644
--- a/libpqpp/unittests/testpq.cpp
+++ b/libpqpp/unittests/testpq.cpp
@@ -112,13 +112,18 @@ BOOST_AUTO_TEST_CASE( selectInTx )
{
auto db = DB::MockDatabase::openConnectionTo("PQmock");
- auto select = db->newSelectCommand("SELECT * FROM test");
- while (select->fetch()) { }
- delete select;
+ // Loop to ensure we can create the same statement several times
+ for (int x = 0; x < 2; x++) {
+ auto select = db->select("SELECT * FROM test");
+ // Loop to ensure we can use the same command several times
+ for (int y = 0; y < 2; y++) {
+ while (select->fetch()) { }
+ }
+ }
db->finish();
db->beginTx();
- select = db->newSelectCommand("SELECT * FROM test");
+ auto select = db->newSelectCommand("SELECT * FROM test");
while (select->fetch()) { }
delete select;
db->commitTx();