diff options
Diffstat (limited to 'libsqlitepp')
-rw-r--r-- | libsqlitepp/connection.cpp | 6 | ||||
-rw-r--r-- | libsqlitepp/connection.h | 2 | ||||
-rw-r--r-- | libsqlitepp/unittests/testsqlite.cpp | 1 |
3 files changed, 9 insertions, 0 deletions
diff --git a/libsqlitepp/connection.cpp b/libsqlitepp/connection.cpp index 50df13e..3331024 100644 --- a/libsqlitepp/connection.cpp +++ b/libsqlitepp/connection.cpp @@ -126,3 +126,9 @@ SQLite::Connection::bulkUploadData(const char *, size_t) const throw Error("Not implemented"); } +int64_t +SQLite::Connection::insertId() const +{ + return sqlite3_last_insert_rowid(db); +} + diff --git a/libsqlitepp/connection.h b/libsqlitepp/connection.h index 95c1aac..f5e2ec4 100644 --- a/libsqlitepp/connection.h +++ b/libsqlitepp/connection.h @@ -27,6 +27,8 @@ namespace SQLite { void endBulkUpload(const char *) const override; size_t bulkUploadData(const char *, size_t) const override; + int64_t insertId() const override; + sqlite3 * db; private: diff --git a/libsqlitepp/unittests/testsqlite.cpp b/libsqlitepp/unittests/testsqlite.cpp index 6f88075..62764bd 100644 --- a/libsqlitepp/unittests/testsqlite.cpp +++ b/libsqlitepp/unittests/testsqlite.cpp @@ -48,6 +48,7 @@ BOOST_AUTO_TEST_CASE( bindAndSend ) mod->bindParamF(1, testDouble); mod->bindParamS(2, testString); mod->execute(); + BOOST_REQUIRE_EQUAL(2, rw->insertId()); delete mod; rw->commitTx(); delete rw; |