From: Jess Robinson Date: Tue, 1 Jul 2008 12:26:34 +0000 (+0000) Subject: Added patch from groditi adding SET type support to the mysql producer X-Git-Tag: v0.11008~309 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=7c1aae0273e6d64e48e3656bd99337cb83d63e89;p=dbsrgits%2FSQL-Translator.git Added patch from groditi adding SET type support to the mysql producer --- diff --git a/Changes b/Changes index e8741f4..b76a343 100644 --- a/Changes +++ b/Changes @@ -1,4 +1,5 @@ +* Added support for SET fields in the mysql producer + test (groditi) * Added support for proper booleans in the mysql producer, when a mysql version of at least 4.x is supplied * Added support for proper enums under pg (as of 8.3), with pg version check, and deferrable constraints * Added support to truncate long constraint and index names in the mysql producer, because of a change to DBIx::Class to produce such long names in some cases. diff --git a/lib/SQL/Translator/Producer/MySQL.pm b/lib/SQL/Translator/Producer/MySQL.pm index 307ef6a..0ec71f1 100644 --- a/lib/SQL/Translator/Producer/MySQL.pm +++ b/lib/SQL/Translator/Producer/MySQL.pm @@ -457,9 +457,9 @@ sub create_field $field_def .= " $data_type"; - if ( lc $data_type eq 'enum' ) { + if ( lc($data_type) eq 'enum' || lc($data_type) eq 'set') { $field_def .= '(' . $commalist . ')'; - } + } elsif ( defined $size[0] && $size[0] > 0 ) { $field_def .= '(' . join( ', ', @size ) . ')'; } diff --git a/t/38-mysql-producer.t b/t/38-mysql-producer.t index b909e93..39b127e 100644 --- a/t/38-mysql-producer.t +++ b/t/38-mysql-producer.t @@ -94,13 +94,23 @@ schema: data_type: int order: 2 is_not_null: 1 + bar_set: + name: bar_set + data_type: set + order: 3 + is_not_null: 1 + extra: + list: + - foo + - bar + - baz indices: - type: NORMAL - fields: + fields: - id name: index_1 - type: NORMAL - fields: + fields: - id name: really_long_name_bigger_than_64_chars_aaaaaaaaaaaaaaaaaaaaaaaaaaa constraints: @@ -137,6 +147,7 @@ my @stmts = ( `id` integer, `foo` integer, `foo2` integer, + `bar_set` set('foo', 'bar', 'baz'), INDEX index_1 (`id`), INDEX really_long_name_bigger_than_64_chars_aaaaaaaaaaaaaaaaa_aed44c47 (`id`), INDEX (`foo`),