aboutsummaryrefslogtreecommitdiff
path: root/common/composite-id/test.hxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2012-04-27 11:36:43 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2012-04-27 11:36:43 +0200
commitc8458a266eb258cf61b1e66066c72a2dc0f0ad8b (patch)
treec51449d2e0ad3100d80eedb91178e55264d13882 /common/composite-id/test.hxx
parent6a3ddb6bd80f3c0c4d7b6957cb7be1f3d8713720 (diff)
Add support for NULL pointers to objects with composite object ids
Diffstat (limited to 'common/composite-id/test.hxx')
-rw-r--r--common/composite-id/test.hxx54
1 files changed, 53 insertions, 1 deletions
diff --git a/common/composite-id/test.hxx b/common/composite-id/test.hxx
index 512c980..9c2b2b3 100644
--- a/common/composite-id/test.hxx
+++ b/common/composite-id/test.hxx
@@ -414,8 +414,60 @@ namespace test7
inline bool
operator== (const object& x, const object& y)
{
- return x.id == y.id && x.ver == y.ver && x.num == y.num ;
+ return x.id == y.id && x.ver == y.ver && x.num == y.num;
}
}
+// Test composite NULL pointers.
+//
+#pragma db namespace table("t8_")
+namespace test8
+{
+ #pragma db object
+ struct object1
+ {
+ object1 () {}
+ object1 (scomp const& i, unsigned long n): id (i), num (n) {}
+
+ #pragma db id
+ scomp id;
+
+ unsigned long num;
+ };
+
+ inline bool
+ operator== (const object1& x, const object1& y)
+ {
+ return x.id == y.id && x.num == y.num;
+ }
+
+ #pragma db object
+ struct object2
+ {
+ object2 (): o1 (0) {}
+ ~object2 () {delete o1;}
+
+ #pragma db id auto
+ unsigned long id;
+
+ object1* o1;
+ };
+
+ #pragma db object
+ struct object3
+ {
+ ~object3 ()
+ {
+ for (std::vector<object1*>::iterator i (o1.begin ());
+ i != o1.end (); ++i)
+ delete *i;
+ }
+
+ #pragma db id auto
+ unsigned long id;
+
+ std::vector<object1*> o1;
+ };
+}
+
#endif // TEST_HXX