From 55b8c97ae06dd7902d3dc47eece04890ecaf30bc Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sun, 1 Apr 2018 13:52:39 +0100 Subject: 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. --- libpqpp/unittests/testpq.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'libpqpp/unittests/testpq.cpp') 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(); -- cgit v1.2.3