diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2012-02-17 10:08:18 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2012-02-22 12:29:43 +0200 |
commit | 3a1eed21d4d5d0e7f6a9f400420fdc28d7be9b61 (patch) | |
tree | 97ba7338fb804c264c9eaaaa41085b08f6483c68 /odb/relational/sqlite/context.cxx | |
parent | 3f73cc933b64d7d9a88325d33a3c33a0e28720c6 (diff) |
Add support for composite object ids
New pragma id_type (member). New test: common/composite-id. The composite
example has also been updated.
Diffstat (limited to 'odb/relational/sqlite/context.cxx')
-rw-r--r-- | odb/relational/sqlite/context.cxx | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/odb/relational/sqlite/context.cxx b/odb/relational/sqlite/context.cxx index b04dcb9..46689bd 100644 --- a/odb/relational/sqlite/context.cxx +++ b/odb/relational/sqlite/context.cxx @@ -365,17 +365,20 @@ namespace relational } sql_type const& context:: - column_sql_type (semantics::data_member& m, string const& kp) + parse_sql_type (string const& t, semantics::data_member& m) { - string key (kp.empty () - ? string ("sqlite-column-sql-type") - : "sqlite-" + kp + "-column-sql-type"); + // If this proves to be too expensive, we can maintain a + // cache of parsed types. + // + data::sql_type_cache::iterator i (data_->sql_type_cache_.find (t)); - if (!m.count (key)) + if (i != data_->sql_type_cache_.end ()) + return i->second; + else { try { - m.set (key, parse_sql_type (column_type (m, kp))); + return (data_->sql_type_cache_[t] = parse_sql_type (t)); } catch (invalid_sql_type const& e) { @@ -385,8 +388,6 @@ namespace relational throw operation_failed (); } } - - return m.get<sql_type> (key); } sql_type context:: |