From 3a1eed21d4d5d0e7f6a9f400420fdc28d7be9b61 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 17 Feb 2012 10:08:18 +0200 Subject: Add support for composite object ids New pragma id_type (member). New test: common/composite-id. The composite example has also been updated. --- odb/relational/pgsql/context.cxx | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'odb/relational/pgsql/context.cxx') diff --git a/odb/relational/pgsql/context.cxx b/odb/relational/pgsql/context.cxx index 8cc4eca..17ceaaa 100644 --- a/odb/relational/pgsql/context.cxx +++ b/odb/relational/pgsql/context.cxx @@ -236,17 +236,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 ("pgsql-column-sql-type") - : "pgsql-" + 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) { @@ -256,8 +259,6 @@ namespace relational throw operation_failed (); } } - - return m.get (key); } sql_type context:: -- cgit v1.1