aboutsummaryrefslogtreecommitdiff
path: root/evolution
diff options
context:
space:
mode:
Diffstat (limited to 'evolution')
-rw-r--r--evolution/soft-delete/driver.cxx64
-rw-r--r--evolution/soft-delete/makefile2
-rw-r--r--evolution/soft-delete/model.hxx30
3 files changed, 95 insertions, 1 deletions
diff --git a/evolution/soft-delete/driver.cxx b/evolution/soft-delete/driver.cxx
index 23f0c9b..d0debce 100644
--- a/evolution/soft-delete/driver.cxx
+++ b/evolution/soft-delete/driver.cxx
@@ -104,6 +104,22 @@ main (int argc, char* argv[])
}
}
+ // Test view with soft-deleted member.
+ //
+ {
+ using namespace test6;
+
+ object o (1);
+ 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.
@@ -255,6 +271,26 @@ main (int argc, char* argv[])
}
}
+ // Test view with soft-deleted member.
+ //
+ {
+ using namespace test6;
+
+ // All the database operations should still include the deleted
+ // members.
+ //
+ {
+ typedef odb::query<view> query;
+ typedef odb::result<view> result;
+
+ transaction t (db->begin ());
+ result r (db->query<view> (query::str == "abc"));
+ result::iterator i (r.begin ());
+ assert (i != r.end () && i->str == "abc" && i->num == 123);
+ t.commit ();
+ }
+ }
+
#endif // DATABASE_SQLITE
// Test soft-deleted container member in a non-versioned object.
@@ -504,6 +540,34 @@ main (int argc, char* argv[])
}
}
+ // Test view with soft-deleted member.
+ //
+ {
+ using namespace test6;
+
+ // Now none of the database operations should include the
+ // deleted members.
+ //
+ {
+ typedef odb::query<view> query;
+ typedef odb::result<view> result;
+
+ transaction t (db->begin ());
+ result r (db->query<view> (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 ();
+ }
+ }
+
#endif // DATABASE_SQLITE
// Test soft-deleted container member in a non-versioned object.
diff --git a/evolution/soft-delete/makefile b/evolution/soft-delete/makefile
index da284c7..12d02a3 100644
--- a/evolution/soft-delete/makefile
+++ b/evolution/soft-delete/makefile
@@ -36,7 +36,7 @@ $(cxx_obj) $(cxx_od): $(common.l.cpp-options)
$(gen): $(odb)
$(gen): odb := $(odb)
-$(gen) $(dist): odb_common_options = --generate-query \
+$(gen) $(dist): odb_common_options = --generate-query --generate-prepared \
--generate-schema --at-once --table-prefix evo_soft_d_
$(gen): odb_common_options += --database $(db_id)
$(gen1) $(dist): export odb_options1 = $(odb_common_options) --init-changelog
diff --git a/evolution/soft-delete/model.hxx b/evolution/soft-delete/model.hxx
index 78a4cfe..6abdd39 100644
--- a/evolution/soft-delete/model.hxx
+++ b/evolution/soft-delete/model.hxx
@@ -148,6 +148,36 @@ namespace MODEL_NAMESPACE(MODEL_VERSION)
#endif
}
+ // Test view with soft-deleted member.
+ //
+ #pragma db namespace table("t6_")
+ namespace test6
+ {
+ #pragma db object
+ struct object
+ {
+ object (unsigned long id = 0): id_ (id) {}
+
+ #pragma db id
+ unsigned long id_;
+
+ std::string str;
+ unsigned long num;
+ };
+
+ #pragma db view object(object)
+ struct view
+ {
+ std::string str;
+ unsigned long num;
+ };
+
+#if MODEL_VERSION == 3
+ #pragma db member(object::str) deleted(3)
+ #pragma db member(view::str) deleted(3)
+#endif
+ }
+
#endif // DATABASE_SQLITE
// Test soft-deleted container member in a non-versioned object.