aboutsummaryrefslogtreecommitdiff
path: root/evolution/drop-table/driver.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2013-09-15 12:46:09 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2013-09-17 12:04:03 +0200
commit8803508751837d96fd0beff60c952fb2044d073f (patch)
tree7b14fdc13d2d9ef67c7731f6bce68e18f6956cca /evolution/drop-table/driver.cxx
parent86a83893351adef44574514c303aa880cf3b6d54 (diff)
Cleanup polymorphic base tables when dropping derived one
Diffstat (limited to 'evolution/drop-table/driver.cxx')
-rw-r--r--evolution/drop-table/driver.cxx58
1 files changed, 46 insertions, 12 deletions
diff --git a/evolution/drop-table/driver.cxx b/evolution/drop-table/driver.cxx
index 0a005b5..9f60214 100644
--- a/evolution/drop-table/driver.cxx
+++ b/evolution/drop-table/driver.cxx
@@ -41,8 +41,6 @@ main (int argc, char* argv[])
{
case 1:
{
- using namespace v2;
-
if (embedded)
{
transaction t (db->begin ());
@@ -53,19 +51,45 @@ main (int argc, char* argv[])
t.commit ();
}
- object1 o1;
- o1.o = new object (1);
- o1.o->str = "abc";
- o1.nums.push_back (1);
- o1.nums.push_back (2);
- o1.nums.push_back (3);
+ {
+ using namespace v2;
+
+ object1 o1;
+ o1.o = new object (1);
+ o1.o->str = "abc";
+ o1.nums.push_back (1);
+ o1.nums.push_back (2);
+ o1.nums.push_back (3);
+
+ {
+ transaction t (db->begin ());
+ db->persist (o1.o);
+ db->persist (o1);
+ t.commit ();
+ }
+ }
+ // Polymorphism test.
+ //
{
- transaction t (db->begin ());
- db->persist (o1.o);
- db->persist (o1);
- t.commit ();
+ // We have to use v3 here because the discriminator includes
+ // the namespace.
+ //
+ using namespace v3;
+
+ base b (123, "abc");
+ derived d1 (234, "bcd");
+ derived d2 (345, "cde");
+
+ {
+ transaction t (db->begin ());
+ db->persist (b);
+ db->persist (d1);
+ db->persist (d2);
+ t.commit ();
+ }
}
+
break;
}
case 2:
@@ -104,6 +128,7 @@ main (int argc, char* argv[])
schema_catalog::migrate_schema_post (*db, 3);
t.commit ();
}
+
break;
}
case 3:
@@ -119,6 +144,15 @@ main (int argc, char* argv[])
t.commit ();
}
+ // Polymorphism test.
+ //
+ {
+ transaction t (db->begin ());
+ assert (size (db->query<root> ()) == 1);
+ assert (size (db->query<base> ()) == 1);
+ t.commit ();
+ }
+
break;
}
default: