From 635d11d74cd873e6f53d05b1d9f091ae112402a5 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 23 Apr 2012 16:48:03 +0200 Subject: Polymorphic inheritance support --- common/readonly/driver.cxx | 12 ++++++++++-- common/readonly/test.hxx | 12 ++++++++++++ 2 files changed, 22 insertions(+), 2 deletions(-) (limited to 'common/readonly') diff --git a/common/readonly/driver.cxx b/common/readonly/driver.cxx index c543f7a..b39ab38 100644 --- a/common/readonly/driver.cxx +++ b/common/readonly/driver.cxx @@ -204,15 +204,20 @@ main (int argc, char* argv[]) // Readonly object. // { + typedef odb::object_traits so_traits; typedef odb::object_traits ro_traits; typedef odb::object_traits rw_traits; + assert (so_traits::column_count == + so_traits::id_column_count + so_traits::readonly_column_count); + assert (ro_traits::column_count == ro_traits::id_column_count + ro_traits::readonly_column_count); assert (rw_traits::column_count != rw_traits::id_column_count + rw_traits::readonly_column_count); + simple_object so (1, 1); ro_object ro_o (1, 1); rw_object rw_o (1, 1); @@ -224,6 +229,7 @@ main (int argc, char* argv[]) { transaction t (db->begin ()); + db->persist (so); db->persist (ro_o); db->persist (rw_o); t.commit (); @@ -234,6 +240,7 @@ main (int argc, char* argv[]) { transaction t (db->begin ()); + //db->update (so); // Compile error. //db->update (ro_o); // Compile error. db->update (rw_o); t.commit (); @@ -241,8 +248,9 @@ main (int argc, char* argv[]) { transaction t (db->begin ()); - db->load (1, ro_o); - db->load (1, rw_o); + db->load (1, so); + db->load (1, ro_o); + db->load (1, rw_o); t.commit (); } diff --git a/common/readonly/test.hxx b/common/readonly/test.hxx index 04250fe..a29a2bd 100644 --- a/common/readonly/test.hxx +++ b/common/readonly/test.hxx @@ -132,6 +132,18 @@ struct container // Readonly object. // +#pragma db object readonly +struct simple_object +{ + simple_object (unsigned long i, unsigned long x): id (i), sv (x) {} + simple_object () {} + + #pragma db id + unsigned long id; + + unsigned long sv; +}; + #pragma db object struct object { -- cgit v1.1