From: Peter Rabbitson Date: Thu, 23 Apr 2009 23:49:52 +0000 (+0000) Subject: Make minor adjustments to the grammars in order to work around https://rt.cpan.org... X-Git-Tag: v0.11008~183 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=9644fab3603b8e6505633b90684a81801fd32178;p=dbsrgits%2FSQL-Translator.git Make minor adjustments to the grammars in order to work around https://rt.cpan.org/Ticket/Display.html?id=45262 PS: Unable to adjust the DB2 parser as the grammar seems to be lost, only the compiled parser is present PPS: The (s?) in all changes above is probably bogus and should be (s). Leaving intact just in case --- diff --git a/lib/SQL/Translator/Parser/MySQL.pm b/lib/SQL/Translator/Parser/MySQL.pm index 5698f74..4cc100c 100644 --- a/lib/SQL/Translator/Parser/MySQL.pm +++ b/lib/SQL/Translator/Parser/MySQL.pm @@ -231,9 +231,9 @@ string : nonstring : /[^;\'"]+/ -statement_body : (string | nonstring)(s?) +statement_body : string | nonstring -insert : /insert/i statement_body "$delimiter" +insert : /insert/i statement_body(s?) "$delimiter" delimiter : /delimiter/i /[\S]+/ { $delimiter = $item[2] } @@ -347,7 +347,7 @@ create : CREATE replace(?) algorithm(?) /view/i NAME not_delimiter "$delimiter" { @table_comments = (); my $view_name = $item[5]; - my $sql = join(q{ }, grep { length } $item[1], $item[2]->[0], $item[3]->[0]) + my $sql = join(q{ }, grep { defined and length } $item[1], $item[2]->[0], $item[3]->[0]) . " $item[4] $item[5] $item[6]"; # Hack to strip database from function calls in SQL diff --git a/lib/SQL/Translator/Parser/PostgreSQL.pm b/lib/SQL/Translator/Parser/PostgreSQL.pm index bfcbd79..7d446c2 100644 --- a/lib/SQL/Translator/Parser/PostgreSQL.pm +++ b/lib/SQL/Translator/Parser/PostgreSQL.pm @@ -198,11 +198,11 @@ string : nonstring : /[^;\'"]+/ -statement_body : (string | nonstring)(s?) +statement_body : string | nonstring -insert : /insert/i statement_body ';' +insert : /insert/i statement_body(s?) ';' -update : /update/i statement_body ';' +update : /update/i statement_body(s?) ';' # # Create table. diff --git a/lib/SQL/Translator/Parser/SQLite.pm b/lib/SQL/Translator/Parser/SQLite.pm index faa22d2..88302f2 100644 --- a/lib/SQL/Translator/Parser/SQLite.pm +++ b/lib/SQL/Translator/Parser/SQLite.pm @@ -459,9 +459,9 @@ string : nonstring : /[^;\'"]+/ -statement_body : (string | nonstring)(s?) +statement_body : string | nonstring -trigger_step : /(select|delete|insert|update)/i statement_body SEMICOLON +trigger_step : /(select|delete|insert|update)/i statement_body(s?) SEMICOLON { $return = join( ' ', $item[1], join ' ', @{ $item[2] || [] } ) }