summaryrefslogtreecommitdiff
path: root/libpqpp/unittests/testpq.cpp
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2015-12-30 06:13:56 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2015-12-30 06:13:56 +0000
commit847a82ddfb4d8c91d69e2b54a98efeffe613b2d0 (patch)
tree253cfc17a58eea9f5bcb4a8fdd8225635f90ead1 /libpqpp/unittests/testpq.cpp
parentImprove and centralise transaction handling logic (diff)
downloadlibdbpp-postgresql-847a82ddfb4d8c91d69e2b54a98efeffe613b2d0.tar.bz2
libdbpp-postgresql-847a82ddfb4d8c91d69e2b54a98efeffe613b2d0.tar.xz
libdbpp-postgresql-847a82ddfb4d8c91d69e2b54a98efeffe613b2d0.zip
Only open select transactions when the connection doesn't already have one
Diffstat (limited to 'libpqpp/unittests/testpq.cpp')
-rw-r--r--libpqpp/unittests/testpq.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/libpqpp/unittests/testpq.cpp b/libpqpp/unittests/testpq.cpp
index ed6c4bc..c49fa34 100644
--- a/libpqpp/unittests/testpq.cpp
+++ b/libpqpp/unittests/testpq.cpp
@@ -80,6 +80,25 @@ BOOST_AUTO_TEST_CASE( bindAndSelect )
delete ro;
}
+BOOST_AUTO_TEST_CASE( selectInTx )
+{
+ auto db = DB::MockDatabase::openConnectionTo("pqmock");
+
+ auto select = db->newSelectCommand("SELECT * FROM test");
+ while (select->fetch()) { }
+ delete select;
+ db->finish();
+
+ db->beginTx();
+ select = db->newSelectCommand("SELECT * FROM test");
+ while (select->fetch()) { }
+ delete select;
+ db->commitTx();
+ db->finish();
+
+ delete db;
+}
+
BOOST_AUTO_TEST_CASE( bindAndSelectOther )
{
auto ro = DB::MockDatabase::openConnectionTo("pqmock");