Skip Menu |

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

Report information
The Basics
Id: 28594
Status: resolved
Priority: 0/
Queue: SQL-Translator

People
Owner: Nobody in particular
Requestors: mmt [...] rahul.net
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: 0.07
Fixed in: 0.11008



Subject: DBI-MySQL parser doesn't handle ENUM well enough for PostgreSQL producer
Although it looks like the "fix" in 0.08 was to comment out the functionality for handling MySQL's ENUM type in the PostgreSQL producer, I find that I need this functionality. I have included a diff against .07 which adds the parsing functionality to the DBI::MySQL parser, which works with the .07 PostgreSQL producer. I have not tested any other combinations, nor have I attempted to work around any other shortcomings.
Subject: DBI-MySQL.pm.diff
--- /usr/share/perl5/SQL/Translator/Parser/DBI/MySQL.pm 2006-07-04 14:42:10.000000000 -0700 +++ Parser/DBI/MySQL.pm 2007-07-31 12:08:50.000000000 -0700 @@ -70,13 +70,32 @@ my $default = $col->{'default'}; my $extra = $col->{'extra'}; - my ( $data_type, $size, $char_set ); + my ( $data_type, $size, $char_set, @list ); # + # set/enum datatype = "SET('a','b')" + # or "ENUM('ab','xyz')" + # + if ( $type =~ m{ + (set|enum) # data type + \( # open paren + ([^)]+) # list items + \) # close paren + }x + ) { + $data_type = $1; + @list = (@list, split(",",$2)); + for (@list) { + s/^\'//; + s/\'$//; + $size = length if !$size || length > $size; + } + } + # # Normal datatype = "int(11)" # or "varchar(20) character set latin1" # - if ( $type =~ m{ + elsif ( $type =~ m{ (\w+) # data type \( # open paren (\d+) # first number @@ -111,6 +130,7 @@ is_auto_increment => $extra eq 'auto_increment', is_nullable => $is_nullable, comments => $extra, + extra => { 'list' => \@list }, ) or die $table->error; $table->primary_key( $field->name ) if $key eq 'PRI';
Apologies for the late response. Parser::DBI::MySQL now just passes the 'SHOW CREATE TABLE' output to Parser::MySQL, which has proper ENUM handling.