aboutsummaryrefslogtreecommitdiff
path: root/common/erase-query
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2011-08-25 11:02:20 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2011-08-25 11:02:20 +0200
commit18dc4c5a4cb46f01ebdd49fbb6baa3c48d8f3b3d (patch)
tree600125a04797d7261e748507c4c3d8eea5eadbf2 /common/erase-query
parentff3950866c0f756a5b6f379b9f95f01fff4a9ec7 (diff)
Add experimental code (commented out) for DELETE JOIN support
This would be needed to support object relationships in the erase_query() functionality.
Diffstat (limited to 'common/erase-query')
-rw-r--r--common/erase-query/driver.cxx35
-rw-r--r--common/erase-query/test.hxx19
2 files changed, 52 insertions, 2 deletions
diff --git a/common/erase-query/driver.cxx b/common/erase-query/driver.cxx
index 67d4e8d..2137377 100644
--- a/common/erase-query/driver.cxx
+++ b/common/erase-query/driver.cxx
@@ -63,7 +63,8 @@ main (int argc, char* argv[])
{
transaction t (db->begin ());
- assert (db->erase_query<object> ("id < 3") == 2);
+ assert (db->erase_query<object> (
+ "common_erase_query_object.id < 3") == 2);
db->erase_query<object> ();
t.commit ();
}
@@ -79,6 +80,38 @@ main (int argc, char* argv[])
t.commit ();
}
+ // Test predicates involving object pointers (DELETE JOIN).
+ //
+ /*
+ {
+ object o11 (1);
+ object o12 (2);
+ object o13 (3);
+ object2 o2;
+
+ o11.o2 = &o2;
+ o2.num = 123;
+
+ o12.o1 = &o13;
+ o13.num = 123;
+
+ transaction t (db->begin ());
+ db->persist (o2);
+ db->persist (o13);
+ db->persist (o12);
+ db->persist (o11);
+ t.commit ();
+ }
+
+ {
+ transaction t (db->begin ());
+ assert (db->erase_query<object> (query::o1::num == 123) == 1);
+ assert (db->erase_query<object> (query::o2::num == 123) == 1);
+ db->erase_query<object> ();
+ t.commit ();
+ }
+ */
+
// Make sure container data is deleted.
//
{
diff --git a/common/erase-query/test.hxx b/common/erase-query/test.hxx
index be5539f..781eedd 100644
--- a/common/erase-query/test.hxx
+++ b/common/erase-query/test.hxx
@@ -10,15 +10,18 @@
#include <odb/core.hxx>
+struct object2;
+
#pragma db object
struct object
{
object (unsigned long id)
- : id_ (id)
+ : id_ (id), o1 (0), o2 (0)
{
}
object ()
+ : o1 (0), o2 (0)
{
}
@@ -26,6 +29,20 @@ struct object
unsigned long id_;
std::vector<int> v;
+
+ int num;
+
+ object* o1;
+ object2* o2;
+};
+
+#pragma db object
+struct object2
+{
+ #pragma db id auto
+ unsigned long id_;
+
+ int num;
};
#endif // TEST_HXX