From: Ken Youens-Clark Date: Fri, 9 May 2003 19:51:04 +0000 (+0000) Subject: Modified to call translator to get schema rather than passing. X-Git-Tag: v0.02~118 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=70944bc5dd22833fe8f5ed0bdb015c1a412155f3;p=dbsrgits%2FSQL-Translator.git Modified to call translator to get schema rather than passing. --- diff --git a/lib/SQL/Translator/Parser/MySQL.pm b/lib/SQL/Translator/Parser/MySQL.pm index 350db0e..6b5e631 100644 --- a/lib/SQL/Translator/Parser/MySQL.pm +++ b/lib/SQL/Translator/Parser/MySQL.pm @@ -1,7 +1,7 @@ package SQL::Translator::Parser::MySQL; # ------------------------------------------------------------------- -# $Id: MySQL.pm,v 1.17 2003-05-09 16:55:07 kycl4rk Exp $ +# $Id: MySQL.pm,v 1.18 2003-05-09 19:51:04 kycl4rk Exp $ # ------------------------------------------------------------------- # Copyright (C) 2003 Ken Y. Clark , # darren chamberlain , @@ -123,7 +123,7 @@ Here's the word from the MySQL site use strict; use vars qw[ $DEBUG $VERSION $GRAMMAR @EXPORT_OK ]; -$VERSION = sprintf "%d.%02d", q$Revision: 1.17 $ =~ /(\d+)\.(\d+)/; +$VERSION = sprintf "%d.%02d", q$Revision: 1.18 $ =~ /(\d+)\.(\d+)/; $DEBUG = 0 unless defined $DEBUG; use Data::Dumper; @@ -456,7 +456,7 @@ VALUE : /[-+]?\.?\d+(?:[eE]\d+)?/ # ------------------------------------------------------------------- sub parse { - my ( $translator, $data, $schema ) = @_; + my ( $translator, $data ) = @_; $parser ||= Parse::RecDescent->new($GRAMMAR); local $::RD_TRACE = $translator->trace ? 1 : undef; @@ -471,6 +471,7 @@ sub parse { die "Parse failed.\n" unless defined $result; warn Dumper( $result ) if $DEBUG; + my $schema = $translator->schema; for my $table_name ( keys %{ $result } ) { my $tdata = $result->{ $table_name }; my $table = $schema->add_table( diff --git a/lib/SQL/Translator/Parser/xSV.pm b/lib/SQL/Translator/Parser/xSV.pm index dff86b8..1bb512c 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.7 2003-05-09 17:15:30 kycl4rk Exp $ +# $Id: xSV.pm,v 1.8 2003-05-09 19:51:04 kycl4rk Exp $ # ------------------------------------------------------------------- # Copyright (C) 2003 Ken Y. Clark , # darren chamberlain @@ -66,7 +66,7 @@ C. use strict; use vars qw($VERSION @EXPORT); -$VERSION = sprintf "%d.%02d", q$Revision: 1.7 $ =~ /(\d+)\.(\d+)/; +$VERSION = sprintf "%d.%02d", q$Revision: 1.8 $ =~ /(\d+)\.(\d+)/; use Exporter; use Text::ParseWords qw(quotewords); @@ -80,7 +80,7 @@ use base qw(Exporter); # Passed a SQL::Translator instance and a string containing the data # sub parse { - my ($tr, $data, $schema) = @_; + my ( $tr, $data ) = @_; my $args = $tr->parser_args; my $parser = Text::RecordParser->new( field_separator => $args->{'field_separator'} || ',', @@ -103,6 +103,7 @@ sub parse { }, }; + my $schema = $tr->schema; my $table = $schema->add_table( name => 'table1' ); #