diff options
Diffstat (limited to 'odb/relational/mysql/context.cxx')
-rw-r--r-- | odb/relational/mysql/context.cxx | 59 |
1 files changed, 27 insertions, 32 deletions
diff --git a/odb/relational/mysql/context.cxx b/odb/relational/mysql/context.cxx index 75b71e9..55dd4f7 100644 --- a/odb/relational/mysql/context.cxx +++ b/odb/relational/mysql/context.cxx @@ -286,15 +286,12 @@ namespace relational bool id, bool* null) { - string r (base_context::database_type_impl (t, hint, id, null)); - - if (!r.empty ()) - return r; - using semantics::enum_; using semantics::enumerator; using semantics::array; + string r; + // Enum mapping. // if (enum_* e = dynamic_cast<enum_*> (&t)) @@ -302,43 +299,41 @@ namespace relational // We can only map to ENUM if the C++ enumeration is contiguous // and starts with 0. // - if (e->unsigned_ ()) + enum_::enumerates_iterator i (e->enumerates_begin ()), + end (e->enumerates_end ()); + + if (i != end) { - enum_::enumerates_iterator i (e->enumerates_begin ()), - end (e->enumerates_end ()); + r += "ENUM("; - if (i != end) + for (unsigned long long j (0); i != end; ++i, ++j) { - r += "ENUM("; - - for (unsigned long long j (0); i != end; ++i, ++j) - { - enumerator const& er (i->enumerator ()); + enumerator const& er (i->enumerator ()); - if (er.value () != j) - break; - - if (j != 0) - r += ", "; + if (er.value () != j) + break; - r += quote_string (er.name ()); - } + if (j != 0) + r += ", "; - if (i == end) - r += ")"; - else - r.clear (); + r += quote_string (er.name ()); } - } - - if (r.empty ()) - { - r = "INT"; - if (e->unsigned_ ()) - r += " UNSIGNED"; + if (i == end) + r += ")"; + else + r.clear (); } + + if (!r.empty ()) + return r; } + + r = base_context::database_type_impl (t, hint, id, null); + + if (!r.empty ()) + return r; + // char[N] mapping. // else if (array* a = dynamic_cast<array*> (&t)) |