From: D. Ilmari Mannsåker Date: Mon, 8 Jul 2013 11:38:22 +0000 (+0100) Subject: Fix MySQL enums with empty strings and leading/trailing quotes (RT#86091) X-Git-Tag: 0.07036~6 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=e238996895ab47aaf7fa837eff1d86f3c2c8db20;p=dbsrgits%2FDBIx-Class-Schema-Loader.git Fix MySQL enums with empty strings and leading/trailing quotes (RT#86091) --- diff --git a/Changes b/Changes index 4148c80..c0b6fa4 100644 --- a/Changes +++ b/Changes @@ -1,6 +1,7 @@ Revision history for Perl extension DBIx::Class::Schema::Loader - Fix stray comma in Pg on_delete/on_update => CASCADE (RT#84706) + - Fix MySQL enums with empty strings and leading/trailing quotes (RT#86091) 0.07035 2013-02-26 - Release 0.07034_01 with a stable version number. 0.07034 is diff --git a/lib/DBIx/Class/Schema/Loader/DBI/mysql.pm b/lib/DBIx/Class/Schema/Loader/DBI/mysql.pm index 2172696..f1e5ae3 100644 --- a/lib/DBIx/Class/Schema/Loader/DBI/mysql.pm +++ b/lib/DBIx/Class/Schema/Loader/DBI/mysql.pm @@ -269,7 +269,7 @@ EOF delete $info->{extra}{list}; - while ($column_type =~ /'((?:[^']* (?:''|\\')* [^']*)* [^\\'])',?/xg) { + while ($column_type =~ /'((?:[^']* (?:''|\\')* [^']*)* [^\\']?)',?/xg) { my $el = $1; $el =~ s/''/'/g; push @{ $info->{extra}{list} }, $el; diff --git a/t/10_02mysql_common.t b/t/10_02mysql_common.t index b251dc7..5d77b75 100644 --- a/t/10_02mysql_common.t +++ b/t/10_02mysql_common.t @@ -136,14 +136,17 @@ my $tester = dbixcsl_common_tests->new( 'longblob' => { data_type => 'longblob' }, 'longtext' => { data_type => 'longtext' }, - "enum('foo','bar','baz')" - => { data_type => 'enum', extra => { list => [qw/foo bar baz/] } }, - "enum('foo \\'bar\\' baz', 'foo ''bar'' quux')" - => { data_type => 'enum', extra => { list => [q{foo 'bar' baz}, q{foo 'bar' quux}] } }, - "set('foo \\'bar\\' baz', 'foo ''bar'' quux')" - => { data_type => 'set', extra => { list => [q{foo 'bar' baz}, q{foo 'bar' quux}] } }, - "set('foo','bar','baz')" - => { data_type => 'set', extra => { list => [qw/foo bar baz/] } }, + ( map { + "$_('','foo','bar','baz')" + => { data_type => $_, extra => { list => ['', qw/foo bar baz/] } }, + "$_('foo \\'bar\\' baz', 'foo ''bar'' quux')" + => { data_type => $_, extra => { list => [q{foo 'bar' baz}, q{foo 'bar' quux}] } }, + "$_('''', '''foo', 'bar''')" + => { data_type => $_, extra => { list => [qw(' 'foo bar')] } }, + "$_('\\'', '\\'foo', 'bar\\'')", + => { data_type => $_, extra => { list => [qw(' 'foo bar')] } }, + } qw(set enum) + ), # RT#68717 "enum('11,10 (<500)/0 DUN','4,90 (<120)/0 EUR') NOT NULL default '11,10 (<500)/0 DUN'"