aboutsummaryrefslogtreecommitdiff
path: root/evolution/soft-delete/model.hxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2013-09-03 12:49:15 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2013-09-17 12:04:02 +0200
commitd3689b6cd0b01ea4872cefbe99dbaef95febd64d (patch)
tree4451ff9338c967b5d430d2145216fca74149e210 /evolution/soft-delete/model.hxx
parent179eb696191958bae891916eec2708c4d3e34983 (diff)
Handling of dynamic empty statements as result of versioning
Diffstat (limited to 'evolution/soft-delete/model.hxx')
-rw-r--r--evolution/soft-delete/model.hxx123
1 files changed, 123 insertions, 0 deletions
diff --git a/evolution/soft-delete/model.hxx b/evolution/soft-delete/model.hxx
new file mode 100644
index 0000000..1690583
--- /dev/null
+++ b/evolution/soft-delete/model.hxx
@@ -0,0 +1,123 @@
+// file : evolution/soft-delete/model.hxx
+// copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC
+// license : GNU GPL v2; see accompanying LICENSE file
+
+#ifndef MODEL_VERSION
+# error model.hxx included directly
+#endif
+
+#include <string>
+
+#include <odb/core.hxx>
+#include <odb/nullable.hxx>
+
+#include <common/config.hxx> // DATABASE_XXX
+
+#pragma db model version(1, MODEL_VERSION)
+
+#define MODEL_NAMESPACE_IMPL(V) v##V
+#define MODEL_NAMESPACE(V) MODEL_NAMESPACE_IMPL(V)
+
+namespace MODEL_NAMESPACE(MODEL_VERSION)
+{
+ // Test soft-deleted objects.
+ //
+ #pragma db namespace table("t1_")
+ namespace test1
+ {
+ #pragma db object
+ struct object
+ {
+ object (unsigned long id = 0): id_ (id) {}
+
+ #pragma db id
+ unsigned long id_;
+
+ unsigned long num;
+ };
+
+#if MODEL_VERSION == 3
+ #pragma db object(object) deleted(3)
+#endif
+ }
+
+ // SQLite doesn't support dropping of columns.
+ //
+#ifndef DATABASE_SQLITE
+
+ // Test basic soft-deleted member logic.
+ //
+ #pragma db namespace table("t2_")
+ namespace test2
+ {
+ #pragma db object
+ struct object
+ {
+ object (unsigned long id = 0): id_ (id) {}
+
+ #pragma db id
+ unsigned long id_;
+
+ std::string str;
+ unsigned long num;
+ };
+
+#if MODEL_VERSION == 3
+ #pragma db member(object::str) deleted(3)
+#endif
+ }
+
+ // Test empty statement handling (INSERT, UPDATE).
+ //
+ #pragma db namespace table("t3_")
+ namespace test3
+ {
+ #pragma db object
+ struct object
+ {
+ #pragma db id auto
+ unsigned long id;
+
+ std::string str;
+ };
+
+#if MODEL_VERSION == 3
+ #pragma db member(object::str) deleted(3)
+#endif
+ }
+
+ // Test empty statement handling (SELECT in polymorphic loader).
+ //
+ #pragma db namespace table("t4_")
+ namespace test4
+ {
+ #pragma db object polymorphic
+ struct base
+ {
+ virtual
+ ~base () {}
+ base (unsigned long id = 0): id_ (id) {}
+
+ #pragma db id
+ unsigned long id_;
+ };
+
+ #pragma db object
+ struct object: base
+ {
+ object (unsigned long id = 0): base (id) {}
+
+ std::string str;
+ };
+
+#if MODEL_VERSION == 3
+ #pragma db member(object::str) deleted(3)
+#endif
+ }
+
+#endif // DATABASE_SQLITE
+
+}
+
+#undef MODEL_NAMESPACE
+#undef MODEL_NAMESPACE_IMPL