From: Ken Youens-Clark Date: Wed, 5 Nov 2003 22:26:02 +0000 (+0000) Subject: Some refinements in assigning field types, size of field for floats. X-Git-Tag: v0.04~30 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=35ea7ccb5780112a25d047c89d81e592564c4477;p=dbsrgits%2FSQL-Translator.git Some refinements in assigning field types, size of field for floats. --- diff --git a/lib/SQL/Translator/Parser/xSV.pm b/lib/SQL/Translator/Parser/xSV.pm index 7813a9a..d3d28a0 100644 --- a/lib/SQL/Translator/Parser/xSV.pm +++ b/lib/SQL/Translator/Parser/xSV.pm @@ -1,7 +1,7 @@ package SQL::Translator::Parser::xSV; # ------------------------------------------------------------------- -# $Id: xSV.pm,v 1.13 2003-10-10 15:59:03 kycl4rk Exp $ +# $Id: xSV.pm,v 1.14 2003-11-05 22:26:02 kycl4rk Exp $ # ------------------------------------------------------------------- # Copyright (C) 2003 Ken Y. Clark , # darren chamberlain @@ -68,7 +68,7 @@ C. use strict; use vars qw($VERSION @EXPORT); -$VERSION = sprintf "%d.%02d", q$Revision: 1.13 $ =~ /(\d+)\.(\d+)/; +$VERSION = sprintf "%d.%02d", q$Revision: 1.14 $ =~ /(\d+)\.(\d+)/; use Exporter; use Text::ParseWords qw(quotewords); @@ -144,8 +144,9 @@ sub parse { $data =~ /^-?\.\d+$/ ) { $type = 'float'; - my ( $w, $d ) = map { s/,//g; $_ } split( /\./, $data ); - $size = [ length $w + length $d, length $d ]; + my ( $w, $d ) = + map { s/,//g; length $_ || 1 } split( /\./, $data ); + $size = [ $w + $d, $d ]; } else { $type = 'char'; @@ -166,8 +167,9 @@ sub parse { for my $field ( keys %field_info ) { my $size = $field_info{ $field }{'size'}; my $data_type = - $field_info{ $field }{'char'} ? 'char' : - $field_info{ $field }{'float'} ? 'float' : 'integer'; + $field_info{ $field }{'char'} ? 'char' : + $field_info{ $field }{'float'} ? 'float' : + $field_info{ $field }{'integer'} ? 'integer' : 'char'; my $field = $table->get_field( $field ); $field->size( $size );