aboutsummaryrefslogtreecommitdiff
path: root/common/polymorphism/driver.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2012-04-25 09:04:35 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2012-04-25 09:04:35 +0200
commita93ad74833e3a99a1421fd695a01a1fb15d1f2dd (patch)
treef6ca24bc002c141fe7f9b9ae7bbe54d7772ad95b /common/polymorphism/driver.cxx
parent2cd5cd2f706d0e76784bc297a02f9d655843f699 (diff)
Fix auto id handling in polymorphic objects
Diffstat (limited to 'common/polymorphism/driver.cxx')
-rw-r--r--common/polymorphism/driver.cxx32
1 files changed, 32 insertions, 0 deletions
diff --git a/common/polymorphism/driver.cxx b/common/polymorphism/driver.cxx
index efda095..0c9bf1e 100644
--- a/common/polymorphism/driver.cxx
+++ b/common/polymorphism/driver.cxx
@@ -1821,6 +1821,38 @@ main (int argc, char* argv[])
t.commit ();
}
}
+
+ // Test 12: polymorphic objects with auto id.
+ //
+ {
+ using namespace test12;
+
+ base b (1);
+ derived d (2);
+
+ unsigned long id1, id2;
+
+ // Persist.
+ //
+ {
+ transaction t (db->begin ());
+ id1 = db->persist (b);
+ id2 = db->persist (static_cast<root&> (d));
+ t.commit ();
+ }
+
+ // Load.
+ //
+ {
+ transaction t (db->begin ());
+ auto_ptr<root> pb (db->load<root> (id1));
+ auto_ptr<root> pd (db->load<root> (id2));
+ t.commit ();
+
+ assert (*pb == b);
+ assert (*pd == d);
+ }
+ }
}
catch (const odb::exception& e)
{