From: Jaime Soriano Pastor Date: Tue, 20 Dec 2011 17:06:35 +0000 (+0100) Subject: Integer default sizes are one point smaller if they are unsigned X-Git-Tag: v0.11011~56 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=936e626bc9111bfbe8319a8558fe4c04a58c1008;p=dbsrgits%2FSQL-Translator.git Integer default sizes are one point smaller if they are unsigned --- diff --git a/Changes b/Changes index 0f5a895..43daaf0 100644 --- a/Changes +++ b/Changes @@ -15,6 +15,8 @@ file as indices (and probably other things) get messed up * Workaround for some MySQL quirks on primary key definitions * MySQL producer does not attempt to write out non-existent unique constraint names +* MySQL parser correctly differentiates between signed and unsigned integer column + display sizes # ---------------------------------------------------------- # 0.11010 2011-10-05 diff --git a/lib/SQL/Translator/Parser/MySQL.pm b/lib/SQL/Translator/Parser/MySQL.pm index da2b6f6..5f8d75a 100644 --- a/lib/SQL/Translator/Parser/MySQL.pm +++ b/lib/SQL/Translator/Parser/MySQL.pm @@ -971,29 +971,30 @@ sub parse { # Takes a field, and returns sub normalize_field { my ($field) = @_; - my ($size, $type, $list, $changed) = @_; + my ($size, $type, $list, $unsigned, $changed); $size = $field->size; $type = $field->data_type; $list = $field->extra->{list} || []; + $unsigned = defined($field->extra->{unsigned}); if ( !ref $size && $size eq 0 ) { if ( lc $type eq 'tinyint' ) { - $changed = $size != 4; - $size = 4; + $changed = $size != 4 - $unsigned; + $size = 4 - $unsigned; } elsif ( lc $type eq 'smallint' ) { - $changed = $size != 6; - $size = 6; + $changed = $size != 6 - $unsigned; + $size = 6 - $unsigned; } elsif ( lc $type eq 'mediumint' ) { - $changed = $size != 9; - $size = 9; + $changed = $size != 9 - $unsigned; + $size = 9 - $unsigned; } elsif ( $type =~ /^int(eger)?$/i ) { - $changed = $size != 11 || $type ne 'int'; + $changed = $size != 11 - $unsigned || $type ne 'int'; $type = 'int'; - $size = 11; + $size = 11 - $unsigned; } elsif ( lc $type eq 'bigint' ) { $changed = $size != 20;