diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2015-10-17 22:11:44 +0100 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2015-10-17 22:11:44 +0100 |
commit | cf7a1dc4c55d9388ba4015c36627f507d1b3f73a (patch) | |
tree | 0fe50b1812647f219deae4eef8b2b9727dad39bd /libpqpp/unittests | |
parent | Add override attributes (diff) | |
download | libdbpp-postgresql-cf7a1dc4c55d9388ba4015c36627f507d1b3f73a.tar.bz2 libdbpp-postgresql-cf7a1dc4c55d9388ba4015c36627f507d1b3f73a.tar.xz libdbpp-postgresql-cf7a1dc4c55d9388ba4015c36627f507d1b3f73a.zip |
Add support for getting last insert valuelibdbpp-postgresql-0.9.1
Diffstat (limited to 'libpqpp/unittests')
-rw-r--r-- | libpqpp/unittests/pqschema.sql | 4 | ||||
-rw-r--r-- | libpqpp/unittests/testpq.cpp | 12 |
2 files changed, 16 insertions, 0 deletions
diff --git a/libpqpp/unittests/pqschema.sql b/libpqpp/unittests/pqschema.sql index 80d9183..2a7dd09 100644 --- a/libpqpp/unittests/pqschema.sql +++ b/libpqpp/unittests/pqschema.sql @@ -35,3 +35,7 @@ CREATE TABLE bulktest( id int, string text); +CREATE TABLE idtest( + id serial, + foo int); + diff --git a/libpqpp/unittests/testpq.cpp b/libpqpp/unittests/testpq.cpp index 3942cfd..cf366cb 100644 --- a/libpqpp/unittests/testpq.cpp +++ b/libpqpp/unittests/testpq.cpp @@ -155,5 +155,17 @@ BOOST_AUTO_TEST_CASE( bigIterate ) delete ro; } +BOOST_AUTO_TEST_CASE( insertId ) +{ + auto ro = DB::MockDatabase::openConnectionTo("pqmock"); + auto ins = ro->newModifyCommand("INSERT INTO idtest(foo) VALUES(1)"); + for (int x = 1; x < 4; x++) { + ins->execute(); + BOOST_REQUIRE_EQUAL(x, ro->insertId()); + } + delete ins; + delete ro; +} + BOOST_AUTO_TEST_SUITE_END(); |