aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2011-07-22 14:10:00 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2011-07-22 17:57:00 +0200
commitbc9e3154a6ebe08c65c3be66cf642c30c5c1a726 (patch)
tree77c1bf0021980ce3d2edf1ac3d4be209bbd71917
parentcfc64a1b06cbef49050bc4555a60806b59d90f8b (diff)
Parse and store MySQL ENUM enumerator strings
-rw-r--r--odb/relational/mysql/context.cxx32
-rw-r--r--odb/relational/mysql/context.hxx3
2 files changed, 31 insertions, 4 deletions
diff --git a/odb/relational/mysql/context.cxx b/odb/relational/mysql/context.cxx
index 8fe19fe..84f2bf6 100644
--- a/odb/relational/mysql/context.cxx
+++ b/odb/relational/mysql/context.cxx
@@ -589,11 +589,35 @@ namespace relational
//
if (r.type == sql_type::ENUM || r.type == sql_type::SET)
{
- // Skip tokens until we get the closing paren.
- //
- while (t.type () != sql_token::t_eos &&
- t.punctuation () != sql_token::p_rparen)
+ while (true)
+ {
+ if (t.type () != sql_token::t_string_lit)
+ {
+ cerr << m.file () << ":" << m.line () << ":" << m.column ()
+ << ": error: string literal expected in MySQL ENUM "
+ << "or SET declaration" << endl;
+
+ throw generation_failed ();
+ }
+
+ if (r.type == sql_type::ENUM)
+ r.enumerators.push_back (t.literal ());
+
t = l.next ();
+
+ if (t.punctuation () == sql_token::p_rparen)
+ break;
+ else if (t.punctuation () != sql_token::p_comma)
+ {
+ cerr << m.file () << ":" << m.line () << ":" << m.column ()
+ << ": error: comma expected in MySQL ENUM or "
+ << "SET declaration" << endl;
+
+ throw generation_failed ();
+ }
+
+ t = l.next ();
+ }
}
else
{
diff --git a/odb/relational/mysql/context.hxx b/odb/relational/mysql/context.hxx
index 00ebe57..26568ec 100644
--- a/odb/relational/mysql/context.hxx
+++ b/odb/relational/mysql/context.hxx
@@ -6,6 +6,8 @@
#ifndef ODB_RELATIONAL_MYSQL_CONTEXT_HXX
#define ODB_RELATIONAL_MYSQL_CONTEXT_HXX
+#include <vector>
+
#include <odb/relational/context.hxx>
namespace relational
@@ -72,6 +74,7 @@ namespace relational
bool unsign;
bool range;
unsigned int range_value; // MySQL max value is 2^32 - 1 (LONGBLOG/TEXT).
+ std::vector<std::string> enumerators; // Enumerator strings for ENUM.
};
class context: public virtual relational::context