diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2014-08-14 09:37:06 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2014-11-11 10:29:49 +0200 |
commit | 6fc9edcb2c54d395ea5d9a77bde882cd8ba9ec03 (patch) | |
tree | 0be9e0733fba6b6b1a3fa3ce66e7229a3f8c8de1 | |
parent | d59e3c27450747e5a04585ee9e943376b5bcfa41 (diff) |
Draft implementation for INSERT
-rw-r--r-- | odb/relational/header.cxx | 5 | ||||
-rw-r--r-- | odb/relational/inline.hxx | 15 | ||||
-rw-r--r-- | odb/relational/source.cxx | 19 |
3 files changed, 38 insertions, 1 deletions
diff --git a/odb/relational/header.cxx b/odb/relational/header.cxx index 476aad3..41fdd26 100644 --- a/odb/relational/header.cxx +++ b/odb/relational/header.cxx @@ -208,6 +208,11 @@ traverse_object (type& c) if (!poly_derived && id != 0) { + if (auto_id) + os << "static id_type" << endl + << "id (const id_image_type&);" + << endl; + if (options.generate_query ()) os << "static id_type" << endl << "id (const image_type&);" diff --git a/odb/relational/inline.hxx b/odb/relational/inline.hxx index ed10e09..76a6763 100644 --- a/odb/relational/inline.hxx +++ b/odb/relational/inline.hxx @@ -217,6 +217,7 @@ namespace relational using semantics::data_member; data_member* id (id_member (c)); + bool auto_id (id && auto_ (*id)); bool base_id (id && &id->scope () != &c); // Comes from base. data_member* optimistic (context::optimistic (c)); @@ -251,6 +252,20 @@ namespace relational { if (!poly_derived) { + // id (id_image_type) + // + if (auto_id) + { + os << "inline" << endl + << traits << "::id_type" << endl + << traits << "::" << endl + << "id (const id_image_type& i)" + << "{" + << "return object_traits_impl< " << class_fq_name (*base) << + ", id_" << db << " >::id (i);" + << "}"; + } + // id (image_type) // if (options.generate_query ()) diff --git a/odb/relational/source.cxx b/odb/relational/source.cxx index 33bda4b..6e7ff34 100644 --- a/odb/relational/source.cxx +++ b/odb/relational/source.cxx @@ -174,10 +174,27 @@ traverse_object (type& c) // Functions (abstract and concrete). // - // id (image_type) + // id(), version() // if (!poly_derived && id != 0 && !base_id) { + // id (id_image_type) + // + if (auto_id) + { + os << traits << "::id_type" << endl + << traits << "::" << endl + << "id (const id_image_type& i)" + << "{" + << db << "::database* db (0);" + << "ODB_POTENTIALLY_UNUSED (db);" + << endl + << "id_type id;"; + init_id_value_member_->traverse (*id); + os << "return id;" + << "}"; + } + // id (image) // if (options.generate_query ()) |