diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2010-08-19 11:24:43 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2010-08-19 11:24:43 +0200 |
commit | 3c5b84f94ac786426591d25edf2f6e19d9506859 (patch) | |
tree | c82ae4c78842fe94da68013a74fe3d8834181993 /odb/mysql/source.cxx | |
parent | c39378136e17f556608b3ea649f2ee9c92104670 (diff) |
Add support for automatic object ids
Diffstat (limited to 'odb/mysql/source.cxx')
-rw-r--r-- | odb/mysql/source.cxx | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/odb/mysql/source.cxx b/odb/mysql/source.cxx index 1e91344..9d47541 100644 --- a/odb/mysql/source.cxx +++ b/odb/mysql/source.cxx @@ -838,12 +838,22 @@ namespace mysql << "object_statements<object_type>& sts (" << endl << "conn.statement_cache ().find<object_type> ());" << "binding& b (sts.image_binding ());" - << endl + << endl; + + if (id.count ("auto")) + os << "obj." << id.name () << " = 0;"; + + os << endl << "if (init (sts.image (), obj) || b.version == 0)" << endl << "bind (b, sts.image ());" << endl - << "sts.persist_statement ().execute ();" - << "}"; + << "mysql::persist_statement& st (sts.persist_statement ());" + << "st.execute ();"; + + if (id.count ("auto")) + os << "obj." << id.name () << " = static_cast<id_type> (st.id ());"; + + os << "}"; // store () // |