aboutsummaryrefslogtreecommitdiff
path: root/common/readonly
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2012-04-23 16:48:03 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2012-04-23 16:48:03 +0200
commit635d11d74cd873e6f53d05b1d9f091ae112402a5 (patch)
tree49a9b835aecba11ff666a7d5c34fd1a248881e78 /common/readonly
parentadfa9c5ffccdd4e5db8c545d9106c0eb1d7bdcb8 (diff)
Polymorphic inheritance support
Diffstat (limited to 'common/readonly')
-rw-r--r--common/readonly/driver.cxx12
-rw-r--r--common/readonly/test.hxx12
2 files changed, 22 insertions, 2 deletions
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<simple_object> so_traits;
typedef odb::object_traits<ro_object> ro_traits;
typedef odb::object_traits<rw_object> 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<ro_object> (1, ro_o);
- db->load<ro_object> (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
{