diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2012-04-26 17:16:24 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2012-04-26 17:16:24 +0200 |
commit | 6a3ddb6bd80f3c0c4d7b6957cb7be1f3d8713720 (patch) | |
tree | 1d65d67de11b8f803a2eac496b483a8c1d2bb7e8 /common/readonly/driver.cxx | |
parent | d073555e513e671b197c5eb31c0b2b269f137d0f (diff) |
Add test for readonly object with auto id
Diffstat (limited to 'common/readonly/driver.cxx')
-rw-r--r-- | common/readonly/driver.cxx | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/common/readonly/driver.cxx b/common/readonly/driver.cxx index b39ab38..b67ed4f 100644 --- a/common/readonly/driver.cxx +++ b/common/readonly/driver.cxx @@ -287,6 +287,30 @@ main (int argc, char* argv[]) assert (*o.pl == 2 && *o.cpl == 2 && *o.pcl == 2 && *o.cpcl == 1); } + + // Readonly object with auto id. + // + { + ro_auto o1 (1); + ro_auto o2 (2); + + { + transaction t (db->begin ()); + db->persist (o1); + db->persist (o2); + t.commit (); + } + + { + transaction t (db->begin ()); + auto_ptr<ro_auto> p1 (db->load<ro_auto> (o1.id)); + auto_ptr<ro_auto> p2 (db->load<ro_auto> (o2.id)); + t.commit (); + + assert (p1->num == o1.num); + assert (p2->num == o2.num); + } + } } catch (const odb::exception& e) { |