From ce03afff5ef2e8da677def73079864c31c6618d8 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 24 Jan 2013 15:10:22 +0200 Subject: Add support for mapping char[N] to CHAR/VARCHAR database types Also improve query support for arrays (decaying). --- odb/relational/sqlite/context.cxx | 25 ++++++++++++++++++++++--- odb/relational/sqlite/context.hxx | 2 +- 2 files changed, 23 insertions(+), 4 deletions(-) (limited to 'odb/relational/sqlite') diff --git a/odb/relational/sqlite/context.cxx b/odb/relational/sqlite/context.cxx index 5e46c77..bb3d548 100644 --- a/odb/relational/sqlite/context.cxx +++ b/odb/relational/sqlite/context.cxx @@ -32,7 +32,7 @@ namespace relational { {"bool", "INTEGER", 0, false}, - {"char", "INTEGER", 0, false}, + {"char", "TEXT", 0, false}, {"signed char", "INTEGER", 0, false}, {"unsigned char", "INTEGER", 0, false}, @@ -219,17 +219,36 @@ 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 ()) + { r = "INTEGER"; + } + // char[N] mapping. + // + else if (array* a = dynamic_cast (&t)) + { + semantics::type& bt (a->base_type ()); + if (bt.is_a ()) + { + if (a->size () != 0) + r = "TEXT"; + } + } return r; } diff --git a/odb/relational/sqlite/context.hxx b/odb/relational/sqlite/context.hxx index 6da5b9b..ebba734 100644 --- a/odb/relational/sqlite/context.hxx +++ b/odb/relational/sqlite/context.hxx @@ -77,7 +77,7 @@ namespace relational protected: virtual string - database_type_impl (semantics::type&, semantics::names*, bool); + database_type_impl (semantics::type&, semantics::names*, bool, bool*); public: virtual -- cgit v1.1