aboutsummaryrefslogtreecommitdiff
path: root/odb/relational/pgsql/context.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'odb/relational/pgsql/context.cxx')
-rw-r--r--odb/relational/pgsql/context.cxx39
1 files changed, 36 insertions, 3 deletions
diff --git a/odb/relational/pgsql/context.cxx b/odb/relational/pgsql/context.cxx
index 0f68281..95b30b0 100644
--- a/odb/relational/pgsql/context.cxx
+++ b/odb/relational/pgsql/context.cxx
@@ -31,7 +31,7 @@ namespace relational
{
{"bool", "BOOLEAN", 0, false},
- {"char", "SMALLINT", 0, false},
+ {"char", "CHAR(1)", 0, false},
{"signed char", "SMALLINT", 0, false},
{"unsigned char", "SMALLINT", 0, false},
@@ -230,17 +230,50 @@ namespace relational
}
string context::
- database_type_impl (semantics::type& t, semantics::names* hint, bool id)
+ database_type_impl (semantics::type& t,
+ semantics::names* hint,
+ bool id,
+ bool* null)
{
- string r (base_context::database_type_impl (t, hint, id));
+ string r (base_context::database_type_impl (t, hint, id, null));
if (!r.empty ())
return r;
using semantics::enum_;
+ using semantics::array;
+ // Enum mapping.
+ //
if (t.is_a<semantics::enum_> ())
+ {
r = "INTEGER";
+ }
+ // char[N] mapping.
+ //
+ else if (array* a = dynamic_cast<array*> (&t))
+ {
+ semantics::type& bt (a->base_type ());
+ if (bt.is_a<semantics::fund_char> ())
+ {
+ unsigned long long n (a->size ());
+
+ if (n == 0)
+ return r;
+ else if (n == 1)
+ r = "CHAR(";
+ else
+ {
+ r = "VARCHAR(";
+ n--;
+ }
+
+ ostringstream ostr;
+ ostr << n;
+ r += ostr.str ();
+ r += ')';
+ }
+ }
return r;
}