aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2010-08-03 14:10:31 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2010-08-03 14:10:31 +0200
commitfd183d666dc035dadb7e73378a29975df56f1dfd (patch)
tree38aac5dd31bfe1d83db9260dcea0461a70056cdb
parent2aa4c33c265448789dec61280ee96005295ab2fb (diff)
ENUM and SET MySQL type parsing
-rw-r--r--odb/mysql/context.cxx59
1 files changed, 36 insertions, 23 deletions
diff --git a/odb/mysql/context.cxx b/odb/mysql/context.cxx
index 9f2373f..f3b9bbb 100644
--- a/odb/mysql/context.cxx
+++ b/odb/mysql/context.cxx
@@ -352,38 +352,51 @@ namespace mysql
{
t = l.next ();
- if (t.type () != sql_token::t_int_lit)
+ // ENUM and SET have a list of members instead of the range.
+ //
+ if (r.type == sql_type::ENUM || r.type == sql_type::SET)
{
- cerr << m.file () << ":" << m.line () << ":" << m.column ()
- << " error: integer range expected in MySQL type "
- << "declaration" << endl;
-
- throw generation_failed ();
+ // Skip tokens until we get the closing paren.
+ //
+ while (t.type () != sql_token::t_eos &&
+ t.punctuation () != sql_token::p_rparen)
+ t = l.next ();
}
+ else
+ {
+ if (t.type () != sql_token::t_int_lit)
+ {
+ cerr << m.file () << ":" << m.line () << ":" << m.column ()
+ << " error: integer range expected in MySQL type "
+ << "declaration" << endl;
- unsigned int v;
- istringstream is (t.literal ());
+ throw generation_failed ();
+ }
- if (!(is >> v && is.eof ()))
- {
- cerr << m.file () << ":" << m.line () << ":" << m.column ()
- << " error: invalid range value '" << t.literal ()
- << "'in MySQL type declaration" << endl;
+ unsigned int v;
+ istringstream is (t.literal ());
- throw generation_failed ();
- }
+ if (!(is >> v && is.eof ()))
+ {
+ cerr << m.file () << ":" << m.line () << ":" << m.column ()
+ << " error: invalid range value '" << t.literal ()
+ << "'in MySQL type declaration" << endl;
- r.range = true;
- r.range_value = v;
+ throw generation_failed ();
+ }
- t = l.next ();
+ r.range = true;
+ r.range_value = v;
- if (t.punctuation () == sql_token::p_comma)
- {
- // We have the second range value. Skip it.
- //
- l.next ();
t = l.next ();
+
+ if (t.punctuation () == sql_token::p_comma)
+ {
+ // We have the second range value. Skip it.
+ //
+ l.next ();
+ t = l.next ();
+ }
}
if (t.punctuation () != sql_token::p_rparen)