diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2013-09-06 08:59:19 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2013-09-17 12:04:03 +0200 |
commit | a204ad2d0926919fb19d4f14a2d2c0a5e98acd37 (patch) | |
tree | 2fde6cfb7e019cf39ea02fb72adb51cb094b579b /evolution/soft-delete | |
parent | 2c3dcfeee4fd2adb5a7dbd9af1c8ee02d4664d39 (diff) |
Additional soft-delete tests
Diffstat (limited to 'evolution/soft-delete')
-rw-r--r-- | evolution/soft-delete/driver.cxx | 800 | ||||
-rw-r--r-- | evolution/soft-delete/model.hxx | 174 |
2 files changed, 964 insertions, 10 deletions
diff --git a/evolution/soft-delete/driver.cxx b/evolution/soft-delete/driver.cxx index b81cca0..7acf6e1 100644 --- a/evolution/soft-delete/driver.cxx +++ b/evolution/soft-delete/driver.cxx @@ -81,10 +81,13 @@ main (int argc, char* argv[]) o.str = "abc"; o.num = 123; o.vec.push_back (123); + o.ptr = new object1 (1); + o.ptr->ptrs.push_back (&o); { transaction t (db->begin ()); db->persist (o); + db->persist (*o.ptr); t.commit (); } } @@ -154,6 +157,98 @@ main (int argc, char* argv[]) } } + // Test basic soft-deleted member logic in polymorphic classes. + // + { + // We have to use v3 here because the discriminator includes + // the namespace. + // + using namespace v3::test9; + + object o (1); + o.bstr = "ab"; + o.dstr = "abc"; + o.num = 123; + + { + transaction t (db->begin ()); + db->persist (o); + t.commit (); + } + } + + // Test soft-deleted section member in polymorphic classes. + // + { + // We have to use v3 here because the discriminator includes + // the namespace. + // + using namespace v3::test10; + + object o (1); + o.bstr = "ab"; + o.dstr = "abc"; + o.num = 123; + + { + transaction t (db->begin ()); + db->persist (o); + t.commit (); + } + } + + // Test soft-deleted members of a section in polymorphic classes. + // + { + // We have to use v3 here because the discriminator includes + // the namespace. + // + using namespace v3::test11; + + object o (1); + o.bstr = "ab"; + o.dstr = "abc"; + o.num = 123; + + { + transaction t (db->begin ()); + db->persist (o); + t.commit (); + } + } + + // Test soft-deleted member and optimistic concurrency. + // + { + using namespace test12; + + object o (1); + o.str = "abc"; + o.num = 123; + + { + transaction t (db->begin ()); + db->persist (o); + t.commit (); + } + } + + // Test soft-deleted member in an object without id. + // + { + using namespace test13; + + object o; + o.str = "abc"; + o.num = 123; + + { + transaction t (db->begin ()); + db->persist (o); + t.commit (); + } + } + #endif // DATABASE_SQLITE // Test soft-deleted container member in a non-versioned object. @@ -229,7 +324,8 @@ main (int argc, char* argv[]) { transaction t (db->begin ()); auto_ptr<object> p (db->load<object> (1)); - assert (p->str == "abc" && p->num == 123 && p->vec[0] == 123); + assert (p->str == "abc" && p->num == 123 && + p->vec[0] == 123 && p->ptr->id_ == 1); t.commit (); } @@ -238,10 +334,12 @@ main (int argc, char* argv[]) typedef odb::result<object> result; transaction t (db->begin ()); - result r (db->query<object> (query::str == "abc")); + result r (db->query<object> (query::str == "abc" && + query::ptr->id == 1)); result::iterator i (r.begin ()); assert (i != r.end () && - i->str == "abc" && i->num == 123 && i->vec[0] == 123); + i->str == "abc" && i->num == 123 && + i->vec[0] == 123 && i->ptr->id_ == 1); t.commit (); } @@ -249,24 +347,32 @@ main (int argc, char* argv[]) o.str = "bcd"; o.num = 234; o.vec.push_back (234); + o.ptr = new object1 (2); + o.ptr->ptrs.push_back (&o); { transaction t (db->begin ()); db->persist (o); + db->persist (*o.ptr); auto_ptr<object> p (db->load<object> (2)); - assert (p->str == "bcd" && p->num == 234 && p->vec[0] == 234); + assert (p->str == "bcd" && p->num == 234 && + p->vec[0] == 234 && p->ptr->id_ == 2); t.commit (); } o.str += 'e'; o.num++; o.vec.modify (0)++; + delete o.ptr; + o.ptr = 0; { transaction t (db->begin ()); + db->erase<object1> (2); db->update (o); auto_ptr<object> p (db->load<object> (2)); - assert (p->str == "bcde" && p->num == 235 && p->vec[0] == 235); + assert (p->str == "bcde" && p->num == 235 && + p->vec[0] == 235 && p->ptr == 0); t.commit (); } @@ -467,6 +573,297 @@ main (int argc, char* argv[]) } } + // Test basic soft-deleted member logic in polymorphic classes. + // + { + using namespace test9; + + // All the database operations should still include the deleted + // members. + // + { + transaction t (db->begin ()); + auto_ptr<object> p (static_cast<object*> (db->load<base> (1))); + assert (p->bstr == "ab" && p->dstr == "abc" && p->num == 123); + t.commit (); + } + + { + typedef odb::query<base> query; + typedef odb::result<base> result; + + transaction t (db->begin ()); + result r (db->query<base> (query::bstr == "ab")); + result::iterator i (r.begin ()); + assert (i != r.end ()); + object& o (static_cast<object&> (*i)); + assert (o.bstr == "ab" && o.dstr == "abc" && o.num == 123); + t.commit (); + } + + object o (2); + o.bstr = "bc"; + o.dstr = "bcd"; + o.num = 234; + + { + transaction t (db->begin ()); + db->persist (static_cast<base&> (o)); + auto_ptr<object> p (db->load<object> (2)); + assert (p->bstr == "bc" && p->dstr == "bcd" && p->num == 234); + t.commit (); + } + + o.bstr += 'd'; + o.dstr += 'e'; + o.num++; + + { + transaction t (db->begin ()); + db->update (static_cast<base&> (o)); + auto_ptr<object> p (db->load<object> (2)); + assert (p->bstr == "bcd" && p->dstr == "bcde" && p->num == 235); + t.commit (); + } + + { + transaction t (db->begin ()); + db->erase (static_cast<base&> (o)); + t.commit (); + } + } + + // Test soft-deleted section member in polymorphic classes. + // + { + using namespace test10; + + // All the database operations should still include the deleted + // members. + // + { + transaction t (db->begin ()); + auto_ptr<base> p (db->load<base> (1)); + db->load (*p, p->s); + object& o (static_cast<object&> (*p)); + assert (o.bstr == "ab" && o.dstr == "abc" && o.num == 123); + t.commit (); + } + + { + typedef odb::query<base> query; + typedef odb::result<base> result; + + transaction t (db->begin ()); + result r (db->query<base> (query::bstr == "ab")); + result::iterator i (r.begin ()); + assert (i != r.end ()); + db->load (*i, i->s); + object& o (static_cast<object&> (*i)); + assert (o.bstr == "ab" && o.dstr == "abc" && o.num == 123); + t.commit (); + } + + object o (2); + o.bstr = "bc"; + o.dstr = "bcd"; + o.num = 234; + + { + transaction t (db->begin ()); + db->persist (static_cast<base&> (o)); + auto_ptr<object> p (db->load<object> (2)); + db->load (*p, p->s); + assert (p->bstr == "bc" && p->dstr == "bcd" && p->num == 234); + t.commit (); + } + + o.bstr += 'd'; + o.dstr += 'e'; + o.num++; + o.s.change (); + + { + transaction t (db->begin ()); + db->update (static_cast<base&> (o)); + auto_ptr<object> p (db->load<object> (2)); + db->load (*p, p->s); + assert (p->bstr == "bcd" && p->dstr == "bcde" && p->num == 235); + t.commit (); + } + + { + transaction t (db->begin ()); + db->erase (static_cast<base&> (o)); + t.commit (); + } + } + + // Test soft-deleted members of a section in polymorphic classes. + // + { + using namespace test11; + + // All the database operations should still include the deleted + // members. + // + { + transaction t (db->begin ()); + auto_ptr<base> p (db->load<base> (1)); + db->load (*p, p->s); + object& o (static_cast<object&> (*p)); + assert (o.bstr == "ab" && o.dstr == "abc" && o.num == 123); + t.commit (); + } + + { + typedef odb::query<base> query; + typedef odb::result<base> result; + + transaction t (db->begin ()); + result r (db->query<base> (query::bstr == "ab")); + result::iterator i (r.begin ()); + assert (i != r.end ()); + db->load (*i, i->s); + object& o (static_cast<object&> (*i)); + assert (o.bstr == "ab" && o.dstr == "abc" && o.num == 123); + t.commit (); + } + + object o (2); + o.bstr = "bc"; + o.dstr = "bcd"; + o.num = 234; + + { + transaction t (db->begin ()); + db->persist (static_cast<base&> (o)); + auto_ptr<object> p (db->load<object> (2)); + db->load (*p, p->s); + assert (p->bstr == "bc" && p->dstr == "bcd" && p->num == 234); + t.commit (); + } + + o.bstr += 'd'; + o.dstr += 'e'; + o.num++; + o.s.change (); + + { + transaction t (db->begin ()); + db->update (static_cast<base&> (o)); + auto_ptr<object> p (db->load<object> (2)); + db->load (*p, p->s); + assert (p->bstr == "bcd" && p->dstr == "bcde" && p->num == 235); + t.commit (); + } + + { + transaction t (db->begin ()); + db->erase (static_cast<base&> (o)); + t.commit (); + } + } + + // Test soft-deleted member and optimistic concurrency. + // + { + using namespace test12; + + // All the database operations should still include the deleted + // members. + // + { + transaction t (db->begin ()); + auto_ptr<object> p (db->load<object> (1)); + assert (p->str == "abc" && p->num == 123); + t.commit (); + } + + { + typedef odb::query<object> query; + typedef odb::result<object> result; + + transaction t (db->begin ()); + result r (db->query<object> (query::str == "abc")); + result::iterator i (r.begin ()); + assert (i != r.end () && i->str == "abc" && i->num == 123); + t.commit (); + } + + object o (2); + o.str = "bcd"; + o.num = 234; + + { + transaction t (db->begin ()); + db->persist (o); + auto_ptr<object> p (db->load<object> (2)); + assert (p->str == "bcd" && p->num == 234); + t.commit (); + } + + o.str += 'e'; + o.num++; + + { + transaction t (db->begin ()); + unsigned long long v (o.v_); + db->update (o); + assert (o.v_ != v); + auto_ptr<object> p (db->load<object> (2)); + assert (p->str == "bcde" && p->num == 235 && p->v_ == o.v_); + t.commit (); + } + + { + transaction t (db->begin ()); + db->erase (o); + t.commit (); + } + } + + // Test soft-deleted member in an object without id. + // + { + using namespace test13; + + typedef odb::query<object> query; + typedef odb::result<object> result; + + // All the database operations should still include the deleted + // members. + // + { + transaction t (db->begin ()); + result r (db->query<object> (query::str == "abc")); + result::iterator i (r.begin ()); + assert (i != r.end () && i->str == "abc" && i->num == 123); + t.commit (); + } + + object o; + o.str = "bcd"; + o.num = 234; + + { + transaction t (db->begin ()); + db->persist (o); + + result r (db->query<object> (query::str == "bcd")); + result::iterator i (r.begin ()); + assert (i != r.end () && i->str == "bcd" && i->num == 234); + + t.commit (); + } + + { + transaction t (db->begin ()); + db->erase_query<object> (query::str == "bcd"); + t.commit (); + } + } + #endif // DATABASE_SQLITE // Test soft-deleted container member in a non-versioned object. @@ -627,7 +1024,8 @@ main (int argc, char* argv[]) { transaction t (db->begin ()); auto_ptr<object> p (db->load<object> (1)); - assert (p->str == "" && p->num == 123 && p->vec.empty ()); + assert (p->str == "" && p->num == 123 && + p->vec.empty () && p->ptr == 0); t.commit (); } @@ -639,7 +1037,8 @@ main (int argc, char* argv[]) result r (db->query<object> (query::num == 123)); result::iterator i (r.begin ()); assert (i != r.end () && - i->str == "" && i->num == 123 && i->vec.empty ()); + i->str == "" && i->num == 123 && + i->vec.empty () && i->ptr == 0); try { @@ -655,24 +1054,32 @@ main (int argc, char* argv[]) o.str = "bcd"; o.num = 234; o.vec.push_back (234); + o.ptr = new object1 (2); + o.ptr->ptrs.push_back (&o); { transaction t (db->begin ()); db->persist (o); + db->persist (*o.ptr); auto_ptr<object> p (db->load<object> (2)); - assert (p->str == "" && p->num == 234 && p->vec.empty ()); + assert (p->str == "" && p->num == 234 && + p->vec.empty () && p->ptr == 0); t.commit (); } o.str += 'e'; o.num++; o.vec.modify (0)++; + delete o.ptr; + o.ptr = 0; { transaction t (db->begin ()); + db->erase<object1> (2); db->update (o); auto_ptr<object> p (db->load<object> (2)); - assert (p->str == "" && p->num == 235 && p->vec.empty ()); + assert (p->str == "" && p->num == 235 && + p->vec.empty () && p->ptr == 0); t.commit (); } @@ -938,6 +1345,381 @@ main (int argc, char* argv[]) } } + // Test basic soft-deleted member logic in polymorphic classes. + // + { + using namespace test9; + + // Now none of the database operations should include the + // deleted members. + // + { + transaction t (db->begin ()); + auto_ptr<object> p (static_cast<object*> (db->load<base> (1))); + assert (p->bstr == "" && p->dstr == "" && p->num == 123); + t.commit (); + } + + { + typedef odb::query<base> query; + typedef odb::result<base> result; + + transaction t (db->begin ()); + result r (db->query<base> (query::id == 1)); + result::iterator i (r.begin ()); + assert (i != r.end ()); + object& o (static_cast<object&> (*i)); + assert (o.bstr == "" && o.dstr == "" && o.num == 123); + + try + { + db->query<base> (query::bstr == "ab"); // No such column. + assert (false); + } + catch (const odb::exception&) {} + + t.commit (); + } + + { + typedef odb::query<object> query; + typedef odb::result<object> result; + + transaction t (db->begin ()); + result r (db->query<object> (query::num == 123)); + result::iterator i (r.begin ()); + assert (i != r.end () && + i->bstr == "" && i->dstr == "" && i->num); + + try + { + db->query<object> (query::dstr == "abc"); // No such column. + assert (false); + } + catch (const odb::exception&) {} + + t.commit (); + } + + object o (2); + o.bstr = "bc"; + o.dstr = "bcd"; + o.num = 234; + + { + transaction t (db->begin ()); + db->persist (static_cast<base&> (o)); + auto_ptr<object> p (db->load<object> (2)); + assert (p->bstr == "" && p->dstr == "" && p->num == 234); + t.commit (); + } + + o.bstr += 'd'; + o.dstr += 'e'; + o.num++; + + { + transaction t (db->begin ()); + db->update (static_cast<base&> (o)); + auto_ptr<object> p (db->load<object> (2)); + assert (p->bstr == "" && p->dstr == "" && p->num == 235); + t.commit (); + } + + { + transaction t (db->begin ()); + db->erase<base> (2); + t.commit (); + } + } + + // Test soft-deleted section member in polymorphic classes. + // + { + using namespace test10; + + // Now none of the database operations should include the + // deleted members. + // + { + transaction t (db->begin ()); + auto_ptr<base> p (db->load<base> (1)); + + try + { + db->load (*p, p->s); // No such column. + assert (false); + } + catch (const odb::exception&) {} + + t.commit (); + } + + object o (2); + o.bstr = "bc"; + o.dstr = "bcd"; + o.num = 234; + + { + transaction t (db->begin ()); + db->persist (static_cast<base&> (o)); + t.commit (); + } + + o.bstr += 'd'; + o.dstr += 'e'; + o.num++; + o.s.change (); + + { + transaction t (db->begin ()); + db->update (static_cast<base&> (o)); + t.commit (); + } + + { + transaction t (db->begin ()); + db->erase<base> (2); + t.commit (); + } + } + + // Test soft-deleted members of a section in polymorphic classes. + // + { + using namespace test11; + + // Now none of the database operations should include the + // deleted members. + // + { + transaction t (db->begin ()); + auto_ptr<base> p (db->load<base> (1)); + db->load (*p, p->s); + object& o (static_cast<object&> (*p)); + assert (o.bstr == "" && o.dstr == "" && o.num == 123); + t.commit (); + } + + { + typedef odb::query<base> query; + typedef odb::result<base> result; + + transaction t (db->begin ()); + result r (db->query<base> (query::id == 1)); + result::iterator i (r.begin ()); + db->load (*i, i->s); + assert (i != r.end ()); + object& o (static_cast<object&> (*i)); + assert (o.bstr == "" && o.dstr == "" && o.num == 123); + + try + { + db->query<base> (query::bstr == "ab"); // No such column. + assert (false); + } + catch (const odb::exception&) {} + + t.commit (); + } + + { + typedef odb::query<object> query; + typedef odb::result<object> result; + + transaction t (db->begin ()); + result r (db->query<object> (query::num == 123)); + result::iterator i (r.begin ()); + db->load (*i, i->s); + assert (i != r.end () && + i->bstr == "" && i->dstr == "" && i->num); + + try + { + db->query<object> (query::dstr == "abc"); // No such column. + assert (false); + } + catch (const odb::exception&) {} + + t.commit (); + } + + object o (2); + o.bstr = "bc"; + o.dstr = "bcd"; + o.num = 234; + + { + transaction t (db->begin ()); + db->persist (static_cast<base&> (o)); + auto_ptr<object> p (db->load<object> (2)); + db->load (*p, p->s); + assert (p->bstr == "" && p->dstr == "" && p->num == 234); + t.commit (); + } + + o.bstr += 'd'; + o.dstr += 'e'; + o.num++; + o.s.change (); + + { + transaction t (db->begin ()); + db->update (static_cast<base&> (o)); + auto_ptr<object> p (db->load<object> (2)); + db->load (*p, p->s); + assert (p->bstr == "" && p->dstr == "" && p->num == 235); + t.commit (); + } + + { + transaction t (db->begin ()); + db->erase<base> (2); + t.commit (); + } + + // Test empty statement detection in sections. + // + base b (3); + b.bstr = "bc"; + + { + transaction t (db->begin ()); + db->persist (b); + auto_ptr<base> p (db->load<base> (3)); + db->load (*p, p->s); + assert (p->bstr == ""); + t.commit (); + } + + b.bstr += 'd'; + b.s.change (); + + { + transaction t (db->begin ()); + db->update (b); + auto_ptr<base> p (db->load<base> (3)); + db->load (*p, p->s); + assert (p->bstr == ""); + t.commit (); + } + } + + // Test soft-deleted member and optimistic concurrency. + // + { + using namespace test12; + + // Now none of the database operations should include the + // deleted members. + // + { + transaction t (db->begin ()); + auto_ptr<object> p (db->load<object> (1)); + assert (p->str == "" && p->num == 123); + t.commit (); + } + + { + typedef odb::query<object> query; + typedef odb::result<object> result; + + transaction t (db->begin ()); + result r (db->query<object> (query::num == 123)); + result::iterator i (r.begin ()); + assert (i != r.end () && i->str == "" && i->num == 123); + + try + { + db->query<object> (query::str == "abc"); // No such column. + assert (false); + } + catch (const odb::exception&) {} + + t.commit (); + } + + object o (2); + o.str = "bcd"; + o.num = 234; + + { + transaction t (db->begin ()); + db->persist (o); + auto_ptr<object> p (db->load<object> (2)); + assert (p->str == "" && p->num == 234); + t.commit (); + } + + o.str += 'e'; + o.num++; + + { + transaction t (db->begin ()); + unsigned long long v (o.v_); + db->update (o); + assert (o.v_ != v); + auto_ptr<object> p (db->load<object> (2)); + assert (p->str == "" && p->num == 235 && p->v_ == o.v_); + t.commit (); + } + + { + transaction t (db->begin ()); + db->erase<object> (2); + t.commit (); + } + } + + // Test soft-deleted member in an object without id. + // + { + using namespace test13; + + typedef odb::query<object> query; + typedef odb::result<object> result; + + // Now none of the database operations should include the + // deleted members. + // + { + transaction t (db->begin ()); + result r (db->query<object> (query::num == 123)); + result::iterator i (r.begin ()); + assert (i != r.end () && i->str == "" && i->num == 123); + + try + { + db->query<object> (query::str == "abc"); // No such column. + assert (false); + } + catch (const odb::exception&) {} + + t.commit (); + } + + object o; + o.str = "bcd"; + o.num = 234; + + { + transaction t (db->begin ()); + db->persist (o); + + result r (db->query<object> (query::num == 234)); + result::iterator i (r.begin ()); + assert (i != r.end () && i->str == "" && i->num == 234); + + t.commit (); + } + + { + transaction t (db->begin ()); + db->erase_query<object> (query::num == 234); + t.commit (); + } + } + #endif // DATABASE_SQLITE // Test soft-deleted container member in a non-versioned object. diff --git a/evolution/soft-delete/model.hxx b/evolution/soft-delete/model.hxx index 5defcac..5df2cee 100644 --- a/evolution/soft-delete/model.hxx +++ b/evolution/soft-delete/model.hxx @@ -11,6 +11,7 @@ #include <odb/core.hxx> #include <odb/vector.hxx> #include <odb/section.hxx> +#include <odb/lazy-ptr.hxx> #include <common/config.hxx> // DATABASE_XXX @@ -51,10 +52,24 @@ namespace MODEL_NAMESPACE(MODEL_VERSION) #pragma db namespace table("t2_") namespace test2 { + struct object; + + #pragma db object + struct object1 + { + object1 (unsigned long id = 0): id_ (id) {} + + #pragma db id + unsigned long id_; + + odb::vector<odb::lazy_ptr<object> > ptrs; + }; + #pragma db object struct object { - object (unsigned long id = 0): id_ (id) {} + object (unsigned long id = 0): id_ (id), ptr (0) {} + ~object () {delete ptr;} #pragma db id unsigned long id_; @@ -62,11 +77,15 @@ namespace MODEL_NAMESPACE(MODEL_VERSION) std::string str; unsigned long num; odb::vector<int> vec; + + #pragma db inverse(ptrs) + object1* ptr; }; #if MODEL_VERSION == 3 #pragma db member(object::str) deleted(3) #pragma db member(object::vec) deleted(3) + #pragma db member(object::ptr) deleted(3) #endif } @@ -241,6 +260,159 @@ namespace MODEL_NAMESPACE(MODEL_VERSION) #endif } + // Test basic soft-deleted member logic in polymorphic classes. + // + #pragma db namespace table("t9_") + namespace test9 + { + #pragma db object polymorphic + struct base + { + virtual + ~base () {} + base (unsigned long id = 0): id_ (id) {} + + #pragma db id + unsigned long id_; + + std::string bstr; + }; + + #pragma db object + struct object: base + { + object (unsigned long id = 0): base (id) {} + + std::string dstr; + unsigned long num; + }; + +#if MODEL_VERSION == 3 + #pragma db member(base::bstr) deleted(3) + #pragma db member(object::dstr) deleted(3) +#endif + } + + // Test soft-deleted section member in polymorphic classes. + // + #pragma db namespace table("t10_") + namespace test10 + { + #pragma db object polymorphic + struct base + { + virtual + ~base () {} + base (unsigned long id = 0): id_ (id) {} + + #pragma db id + unsigned long id_; + + #pragma db load(lazy) update(change) + odb::section s; + + #pragma db section(s) + std::string bstr; + }; + + #pragma db object + struct object: base + { + object (unsigned long id = 0): base (id) {} + + #pragma db section(s) + std::string dstr; + + unsigned long num; + }; + +#if MODEL_VERSION == 3 + #pragma db member(base::s) deleted(3) +#endif + } + + // Test soft-deleted members of a section in polymorphic classes. + // + #pragma db namespace table("t11_") + namespace test11 + { + #pragma db object polymorphic + struct base + { + virtual + ~base () {} + base (unsigned long id = 0): id_ (id) {} + + #pragma db id + unsigned long id_; + + #pragma db load(lazy) update(change) + odb::section s; + + #pragma db section(s) + std::string bstr; + }; + + #pragma db object + struct object: base + { + object (unsigned long id = 0): base (id) {} + + #pragma db section(s) + std::string dstr; + + #pragma db section(s) + unsigned long num; + }; + +#if MODEL_VERSION == 3 + #pragma db member(base::bstr) deleted(3) + #pragma db member(object::dstr) deleted(3) +#endif + } + + // Test soft-deleted member and optimistic concurrency. + // + #pragma db namespace table("t12_") + namespace test12 + { + #pragma db object optimistic + struct object + { + object (unsigned long id = 0): id_ (id) {} + + #pragma db id + unsigned long id_; + + #pragma db version mssql:type("ROWVERSION") + unsigned long long v_; + + std::string str; + unsigned long num; + }; + +#if MODEL_VERSION == 3 + #pragma db member(object::str) deleted(3) +#endif + } + + // Test soft-deleted member in an object without id. + // + #pragma db namespace table("t13_") + namespace test13 + { + #pragma db object no_id + struct object + { + std::string str; + unsigned long num; + }; + +#if MODEL_VERSION == 3 + #pragma db member(object::str) deleted(3) +#endif + } + #endif // DATABASE_SQLITE // Test soft-deleted container member in a non-versioned object. |