From: Ken Youens-Clark Date: Tue, 25 Sep 2012 21:33:57 +0000 (-0600) Subject: Allow VALUEs to be enclosed in double and single quotes, specifically X-Git-Tag: v0.011017~28 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=46417fe20ac56566a81da64ce390b8e792a189ff;p=dbsrgits%2FSQL-Translator.git Allow VALUEs to be enclosed in double and single quotes, specifically was a problem on ENUMs, so I added a test for this. --- diff --git a/Changes b/Changes index f707018..3fdbed0 100644 --- a/Changes +++ b/Changes @@ -1,5 +1,6 @@ * De-linkify XML namespace in docs (RT#81838) +* Allow both single and double quotes for values in MySQL parser # ---------------------------------------------------------- # 0.11016 2012-10-09 diff --git a/lib/SQL/Translator/Parser/MySQL.pm b/lib/SQL/Translator/Parser/MySQL.pm index 40ef243..a3ba734 100644 --- a/lib/SQL/Translator/Parser/MySQL.pm +++ b/lib/SQL/Translator/Parser/MySQL.pm @@ -860,17 +860,21 @@ BACKTICK : '`' DOUBLE_QUOTE: '"' +SINGLE_QUOTE: "'" + QUOTED_NAME : BACKTICK /[^`]+/ BACKTICK { $item[2] } | DOUBLE_QUOTE /[^"]+/ DOUBLE_QUOTE { $item[2] } + | SINGLE_QUOTE /[^']+/ SINGLE_QUOTE + { $item[2] } NAME: QUOTED_NAME | /\w+/ VALUE : /[-+]?\.?\d+(?:[eE]\d+)?/ { $item[1] } - | /'.*?'/ + | QUOTED_NAME { # remove leading/trailing quotes my $val = $item[1]; diff --git a/t/02mysql-parser.t b/t/02mysql-parser.t index dbcde4e..ce07de2 100644 --- a/t/02mysql-parser.t +++ b/t/02mysql-parser.t @@ -78,7 +78,7 @@ BEGIN { unsuccessful date default '0000-00-00', i1 int(11) default '0' not null, s1 set('a','b','c') default 'b', - e1 enum('a','b','c') default "c", + e1 enum("a","b","c") default "c", name varchar(30) default NULL, foo_type enum('vk','ck') NOT NULL default 'vk', date timestamp,