Subject: | MySQL parser is too strict on commas |
The following SQL, which is legal for MySQL, generates an error:
CREATE TABLE test (
id INT,
PRIMARY KEY (id),
);
The error is below. Use of trailing commas is convenient to simplify
editing files and can arise as a result of commenting out lines.
ERROR (line 4): Invalid constraint: Was expecting primary key def, or
unique key def, or foreign key def
ERROR (line 4): Invalid index: Was expecting normal index, or fulltext
index
ERROR (line 4): Invalid field: Was expecting field name but found ");"
instead
ERROR (line 4): Invalid create definition: Was expecting constraint, or
index, or field, or comment, or /\\n/
ERROR (line 1): Invalid statement: Was expecting comment, or use, or
set, or drop, or create
Error: translate: Error with parser 'SQL::Translator::Parser::MySQL': no results at /usr/local/bin/sqlt-graph line 160.
Sorry, I'm not familiar enough with Parse::RecDescent to suggest a fix.