Skip Menu |

This queue is for tickets about the SQL-Translator CPAN distribution.

Report information
The Basics
Id: 4838
Status: new
Worked: 1 min
Priority: 0/
Queue: SQL-Translator

People
Owner: kclark [...] cpan.org
Requestors: altblue [...] n0i.net
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 0.04
Fixed in: 0.04



Subject: mysql parser fails on quoted fields/types etc (``)
- MySQL parser fails on `quoted` fields/indexes etc, so I switched some definitions from "WORD" to "NAME"; - replaced "default_val" definition with a more generic RE, allowing many more "default values" (all?) :) - turned global stripping of "'" in "default_val" with left/right trimming - updated VALUE definition to properly parse escaped "'"
- MySQL parser fails on `quoted` fields/indexes etc, so I switched some definitions from "WORD" to "NAME"; - replaced "default_val" definition with a more generic RE, allowing many more "default values" (all?) :) - turned global stripping of "'" in "default_val" with left/right trimming - updated VALUE definition to properly parse escaped "'" --- lib/SQL/Translator/Parser/MySQL.pm.orig 2003-09-08 21:16:04.000000000 +0300 +++ lib/SQL/Translator/Parser/MySQL.pm 2004-01-05 20:59:57.000000000 +0200 @@ -161,7 +161,7 @@ | create | <error> -use : /use/i WORD ';' +use : /use/i NAME ';' { @table_comments = () } set : /set/i /[^;]+/ ';' @@ -169,10 +169,10 @@ drop : /drop/i TABLE /[^;]+/ ';' -drop : /drop/i WORD(s) ';' +drop : /drop/i NAME(s) ';' { @table_comments = () } -create : CREATE /database/i WORD ';' +create : CREATE /database/i NAME ';' { @table_comments = () } create : CREATE TEMPORARY(?) TABLE opt_if_not_exists(?) table_name '(' create_definition(s /,/) ')' table_option(s?) ';' @@ -364,9 +364,9 @@ field_name : NAME -index_name : WORD +index_name : NAME -data_type : WORD parens_value_list(s?) type_qualifier(s?) +data_type : NAME parens_value_list(s?) type_qualifier(s?) { my $type = $item[1]; my $size; # field size, applicable only to non-set fields @@ -435,7 +435,7 @@ type_qualifier : /(BINARY|UNSIGNED|ZEROFILL)/i { lc $item[1] } -field_type : WORD +field_type : NAME create_index : /create/i /index/i @@ -443,9 +443,9 @@ unsigned : /unsigned/i { $return = 0 } -default_val : /default/i /(?:')?[\s\w\d:.-]*(?:')?/ +default_val : /default/i /'(?:.*?\\')*.*?'|(?:')?[\w\d:.-]*(?:')?/ { - $item[2] =~ s/'//g; + $item[2] =~ s/^'|'$//g; $return = $item[2]; } @@ -543,7 +543,7 @@ VALUE : /[-+]?\.?\d+(?:[eE]\d+)?/ { $item[1] } - | /'.*?'/ + | /'(?:.*?\\')*.*?'/ { # remove leading/trailing quotes my $val = $item[1];
Sorry for the delay in responding. Can you provide a diff so I can make sure to apply all the changes you described? Also, please provide a minimum test case that fails with the current version? Thanks for the report! ky