From 87abcad59a90a9a9ce8809cdf51bea7fc5901baf Mon Sep 17 00:00:00 2001 From: Constantin Michael Date: Tue, 5 Jul 2011 12:45:15 +0200 Subject: Add enum support to PostgreSQL --- odb/relational/pgsql/context.cxx | 24 ++++++++++++++++++++++++ odb/relational/pgsql/context.hxx | 5 +---- 2 files changed, 25 insertions(+), 4 deletions(-) (limited to 'odb/relational') diff --git a/odb/relational/pgsql/context.cxx b/odb/relational/pgsql/context.cxx index ea18d1f..082800d 100644 --- a/odb/relational/pgsql/context.cxx +++ b/odb/relational/pgsql/context.cxx @@ -210,6 +210,30 @@ namespace relational return r; } + string context:: + database_type_impl (semantics::type& t, + semantics::names* hint, + semantics::context& ctx, + column_type_flags f) + { + string r (base_context::database_type_impl (t, hint, ctx, f)); + + if (!r.empty ()) + return r; + + using semantics::enum_; + + if (t.is_a ()) + { + r = "INTEGER"; + + if ((f & ctf_default_null) == 0) + r += " NOT NULL"; + } + + return r; + } + // // SQL type parsing. // diff --git a/odb/relational/pgsql/context.hxx b/odb/relational/pgsql/context.hxx index 3190bb3..66d9318 100644 --- a/odb/relational/pgsql/context.hxx +++ b/odb/relational/pgsql/context.hxx @@ -88,10 +88,7 @@ namespace relational database_type_impl (semantics::type& t, semantics::names* hint, semantics::context& ctx, - column_type_flags f) - { - return base_context::database_type_impl (t, hint, ctx, f); - } + column_type_flags f); public: virtual -- cgit v1.1