From 29c78d04e7371b21fbc3e7aef07b17ffd651e4f1 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Wed, 30 Dec 2015 06:13:56 +0000 Subject: Only open select transactions when the connection doesn't already have one --- libpqpp/unittests/testpq.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'libpqpp/unittests/testpq.cpp') 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"); -- cgit v1.2.3