Mercurial > hg > orthanc
diff UnitTests/SQLite.cpp @ 137:0e97abc7b950
fix of a bug in older versions of sqlite
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 10 Oct 2012 13:13:14 +0200 |
parents | f1d0470ff334 |
children |
line wrap: on
line diff
--- a/UnitTests/SQLite.cpp Tue Oct 09 18:21:01 2012 +0200 +++ b/UnitTests/SQLite.cpp Wed Oct 10 13:13:14 2012 +0200 @@ -3,6 +3,7 @@ #include "../Core/Toolbox.h" #include "../Core/SQLite/Connection.h" #include "../Core/SQLite/Statement.h" +#include "../Core/SQLite/Transaction.h" #include <sqlite3.h> @@ -202,3 +203,36 @@ ASSERT_TRUE(func->deleted_.find(4300) != func->deleted_.end()); ASSERT_TRUE(func->deleted_.find(4301) != func->deleted_.end()); } + + +TEST(SQLite, EmptyTransactions) +{ + try + { + SQLite::Connection c; + c.OpenInMemory(); + + c.Execute("CREATE TABLE a(id INTEGER PRIMARY KEY);"); + c.Execute("INSERT INTO a VALUES(NULL)"); + + { + SQLite::Transaction t(c); + t.Begin(); + { + SQLite::Statement s(c, SQLITE_FROM_HERE, "SELECT * FROM a"); + s.Step(); + } + //t.Commit(); + } + + { + SQLite::Statement s(c, SQLITE_FROM_HERE, "SELECT * FROM a"); + s.Step(); + } + } + catch (OrthancException& e) + { + fprintf(stderr, "Exception: [%s]\n", e.What()); + throw e; + } +}