The default too often was "tinyint," changed to only make it that when
Ken Youens-Clark [Mon, 20 Sep 2004 20:22:47 +0000 (20:22 +0000)]
necessary and default non-float number fields to "int."

lib/SQL/Translator/Producer/MySQL.pm

index 4721469..a64a73c 100644 (file)
@@ -1,7 +1,7 @@
 package SQL::Translator::Producer::MySQL;
 
 # -------------------------------------------------------------------
-# $Id: MySQL.pm,v 1.38 2004-09-17 21:54:43 kycl4rk Exp $
+# $Id: MySQL.pm,v 1.39 2004-09-20 20:22:47 kycl4rk Exp $
 # -------------------------------------------------------------------
 # Copyright (C) 2002-4 SQLFairy Authors
 #
@@ -44,7 +44,7 @@ for fields, etc.).
 
 use strict;
 use vars qw[ $VERSION $DEBUG ];
-$VERSION = sprintf "%d.%02d", q$Revision: 1.38 $ =~ /(\d+)\.(\d+)/;
+$VERSION = sprintf "%d.%02d", q$Revision: 1.39 $ =~ /(\d+)\.(\d+)/;
 $DEBUG   = 0 unless defined $DEBUG;
 
 use Data::Dumper;
@@ -126,19 +126,19 @@ sub produce {
             # Oracle "number" type -- figure best MySQL type
             #
             if ( lc $data_type eq 'number' ) {
-                # not an integer
-                if ( scalar @size > 1 ) {
-                    $data_type = 'double';
-                }
-                elsif ( $size[0] >= 12 ) {
-                    $data_type = 'bigint';
-                }
-                elsif ( $size[0] <= 1 ) {
-                    $data_type = 'tinyint';
-                }
-                else {
-                    $data_type = 'int';
+                if ( @size && $size[0] > 0 ) {
+                    # not an integer
+                    if ( scalar @size > 1 ) {
+                        $data_type = 'double';
+                    }
+                    elsif ( $size[0] >= 12 ) {
+                        $data_type = 'bigint';
+                    }
+                    elsif ( $size[0] <= 1 ) {
+                        $data_type = 'tinyint';
+                    }
                 }
+                $data_type ||= 'int';
             }
             #
             # Convert a large Oracle varchar to "text"