to show success.
my $schema = $tr->schema;
my $table_no = 0;
- my %parsed;
my $wb_count = $wb->{'SheetCount'} || 0;
for my $num ( 0 .. $wb_count - 1 ) {
$table_no++;
my @cols = $ws->ColRange;
next unless $cols[1] > 0;
- $parsed{ $table_name } = {
- table_name => $table_name,
- type => undef,
- indices => [ {} ],
- fields => { },
- };
my $table = $schema->add_table( name => $table_name );
for my $col ( $cols[0] .. $cols[1] ) {
my $col_name = normalize_name( $cell->{'Val'} );
my $data_type = ET_to_ST( $cell->{'Type'} );
- $parsed{ $table_name }{'fields'}{ $col_name } = {
- type => 'field',
- order => $col,
- name => $col_name,
- data_type => $data_type,
- size => [ 255 ],
- null => 1,
- default => '',
- is_auto_inc => undef,
-
- # first field is the primary key
- is_primary_key => ($col == 0) ? 1 : undef,
- };
-
my $field = $table->add_field(
name => $col_name,
data_type => $data_type,
}
}
- return \%parsed;
+ return 1;
}
sub ET_to_ST {
package SQL::Translator::Parser::MySQL;
# -------------------------------------------------------------------
-# $Id: MySQL.pm,v 1.24 2003-06-06 22:37:25 kycl4rk Exp $
+# $Id: MySQL.pm,v 1.25 2003-06-11 03:59:49 kycl4rk Exp $
# -------------------------------------------------------------------
# Copyright (C) 2003 Ken Y. Clark <kclark@cpan.org>,
# darren chamberlain <darren@cpan.org>,
use strict;
use vars qw[ $DEBUG $VERSION $GRAMMAR @EXPORT_OK ];
-$VERSION = sprintf "%d.%02d", q$Revision: 1.24 $ =~ /(\d+)\.(\d+)/;
+$VERSION = sprintf "%d.%02d", q$Revision: 1.25 $ =~ /(\d+)\.(\d+)/;
$DEBUG = 0 unless defined $DEBUG;
use Data::Dumper;
}
}
- return $result;
+ return 1;
}
1;
package SQL::Translator::Parser::Oracle;
# -------------------------------------------------------------------
-# $Id: Oracle.pm,v 1.3 2003-06-09 02:16:02 kycl4rk Exp $
+# $Id: Oracle.pm,v 1.4 2003-06-11 03:59:49 kycl4rk Exp $
# -------------------------------------------------------------------
# Copyright (C) 2003 Ken Y. Clark <kclark@cpan.org>
#
use strict;
use vars qw[ $DEBUG $VERSION $GRAMMAR @EXPORT_OK ];
-$VERSION = sprintf "%d.%02d", q$Revision: 1.3 $ =~ /(\d+)\.(\d+)/;
+$VERSION = sprintf "%d.%02d", q$Revision: 1.4 $ =~ /(\d+)\.(\d+)/;
$DEBUG = 0 unless defined $DEBUG;
use Data::Dumper;
}
}
- return $result;
+ return 1;
}
1;
package SQL::Translator::Parser::PostgreSQL;
# -------------------------------------------------------------------
-# $Id: PostgreSQL.pm,v 1.16 2003-06-09 02:41:31 kycl4rk Exp $
+# $Id: PostgreSQL.pm,v 1.17 2003-06-11 03:59:49 kycl4rk Exp $
# -------------------------------------------------------------------
# Copyright (C) 2003 Ken Y. Clark <kclark@cpan.org>,
# Allen Day <allenday@users.sourceforge.net>,
use strict;
use vars qw[ $DEBUG $VERSION $GRAMMAR @EXPORT_OK ];
-$VERSION = sprintf "%d.%02d", q$Revision: 1.16 $ =~ /(\d+)\.(\d+)/;
+$VERSION = sprintf "%d.%02d", q$Revision: 1.17 $ =~ /(\d+)\.(\d+)/;
$DEBUG = 0 unless defined $DEBUG;
use Data::Dumper;
}
}
- return $result;
+ return 1;
}
1;
package SQL::Translator::Parser::xSV;
# -------------------------------------------------------------------
-# $Id: xSV.pm,v 1.9 2003-06-06 00:05:44 kycl4rk Exp $
+# $Id: xSV.pm,v 1.10 2003-06-11 03:59:49 kycl4rk Exp $
# -------------------------------------------------------------------
# Copyright (C) 2003 Ken Y. Clark <kclark@cpan.org>,
# darren chamberlain <darren@cpan.org>
use strict;
use vars qw($VERSION @EXPORT);
-$VERSION = sprintf "%d.%02d", q$Revision: 1.9 $ =~ /(\d+)\.(\d+)/;
+$VERSION = sprintf "%d.%02d", q$Revision: 1.10 $ =~ /(\d+)\.(\d+)/;
use Exporter;
use Text::ParseWords qw(quotewords);
$parser->field_filter( sub { $_ = shift; s/^\s+|\s+$//g; $_ } )
unless defined $args->{'trim_fields'} && $args->{'trim_fields'} == 0;
- #
- # Create skeleton structure, mostly empty.
- #
- my $parsed = {
- table1 => {
- type => undef,
- indices => [ { } ],
- fields => { },
- },
- };
-
my $schema = $tr->schema;
my $table = $schema->add_table( name => 'table1' );
my @field_names = $parser->field_list;
for ( my $i = 0; $i < @field_names; $i++ ) {
- $parsed->{'table1'}{'fields'}{ $field_names[$i] } = {
- type => 'field',
- order => $i,
- name => $field_names[$i],
-
- # Default datatype is "char"
- data_type => 'char',
-
- # default size is 8bits; something more reasonable?
- size => [ 255 ],
- null => 1,
- default => '',
- is_auto_inc => undef,
-
- # field field is the primary key
- is_primary_key => ($i == 0) ? 1 : undef,
- };
-
my $field = $table->add_field(
name => $field_names[$i],
data_type => 'char',
$field_info{ $field }{'char'} ? 'char' :
$field_info{ $field }{'float'} ? 'float' : 'integer';
- $parsed->{'table1'}{'fields'}{ $field }{'size'} =
- $field_info{ $field }{'size'};
-
- $parsed->{'table1'}{'fields'}{ $field }{'data_type'} = $data_type;
-
my $field = $table->get_field( $field );
$field->size( $size );
$field->data_type( $data_type );
}
}
- #
- # Field 0 is primary key, by default, so add an index
- #
- for ( $parsed->{'table1'}->{'indices'}->[0] ) {
- $_->{'type'} = 'primary_key';
- $_->{'name'} = undef;
- $_->{'fields'} = [ $field_names[0] ];
- }
-
- return $parsed;
+ return 1;
}
1;