File tree Expand file tree Collapse file tree 2 files changed +17
-4
lines changed Expand file tree Collapse file tree 2 files changed +17
-4
lines changed Original file line number Diff line number Diff line change @@ -80,7 +80,7 @@ namespace sqlite {
8080 _inx (other._inx), execution_started(other.execution_started) { }
8181
8282 void execute ();
83-
83+
8484 std::string sql () {
8585#if SQLITE_VERSION_NUMBER >= 3014000
8686 auto sqlite_deleter = [](void *ptr) {sqlite3_free (ptr);};
@@ -101,7 +101,7 @@ namespace sqlite {
101101 _next_index ();
102102 --_inx;
103103 }
104- execution_started = state;
104+ execution_started = state;
105105 }
106106 bool used () const { return execution_started; }
107107 row_iterator begin ();
@@ -445,7 +445,7 @@ namespace sqlite {
445445 Values&&... values
446446 );
447447 }
448-
448+
449449 enum class OpenFlags {
450450 READONLY = SQLITE_OPEN_READONLY,
451451 READWRITE = SQLITE_OPEN_READWRITE,
@@ -521,6 +521,10 @@ namespace sqlite {
521521 return sqlite3_last_insert_rowid (_db.get ());
522522 }
523523
524+ int rows_modified () const {
525+ return sqlite3_changes (_db.get ());
526+ }
527+
524528 template <typename Function>
525529 void define (const std::string &name, Function&& func) {
526530 typedef utility::function_traits<Function> traits;
Original file line number Diff line number Diff line change 33#include < cstdlib>
44#include < sqlite_modern_cpp.h>
55#include < catch.hpp>
6- using namespace sqlite ;
6+ using namespace sqlite ;
77using namespace std ;
88
99TEST_CASE (" simple examples" , " [examples]" ) {
@@ -23,5 +23,14 @@ TEST_CASE("simple examples", "[examples]") {
2323 db << sql >> test;
2424
2525 REQUIRE (test == 2 );
26+
27+ db << " UPDATE foo SET b=? WHERE a=?;" << " hi" << 1L ;
28+ db << " SELECT b FROM foo WHERE a=?;" << 1L >> str;
2629
30+ REQUIRE (str == " hi" );
31+ REQUIRE (db.rows_modified () == 1 );
32+
33+ db << " UPDATE foo SET b=?;" << " hello world" ;
34+
35+ REQUIRE (db.rows_modified () == 2 );
2736}
You can’t perform that action at this time.
0 commit comments