#!/usr/bin/perl -w
# -------------------------------------------------------------------
-# $Id: sql_translator.pl,v 1.9 2003-05-12 14:48:43 kycl4rk Exp $
+# $Id: sql_translator.pl,v 1.10 2003-06-16 18:16:25 kycl4rk Exp $
# -------------------------------------------------------------------
# Copyright (C) 2002 Ken Y. Clark <kycl4rk@users.sourceforge.net>,
# darren chamberlain <darren@cpan.org>
use Data::Dumper;
use vars qw( $VERSION );
-$VERSION = sprintf "%d.%02d", q$Revision: 1.9 $ =~ /(\d+)\.(\d+)/;
+$VERSION = sprintf "%d.%02d", q$Revision: 1.10 $ =~ /(\d+)\.(\d+)/;
my $from; # the original database
my $to; # the destination database
my $no_comments; # whether to put comments in out file
my $show_warnings; # whether to show warnings from SQL::Translator
my $add_drop_table; # whether to show warnings from SQL::Translator
-my $xlate; # user overrides for field translation
my $debug; # whether to print debug info
my $trace; # whether to print parser trace
my $list; # list all parsers and producers
my $no_scan; # don't scan xSV fields for data types and sizes
my $field_separator; # for xSV files
my $record_separator; # for xSV files
+my $validate; # whether to validate the parsed document
#
# Get options, explain how to use the script if necessary.
'no-comments' => \$no_comments,
'show-warnings' => \$show_warnings,
'add-drop-table' => \$add_drop_table,
+ 'v|validate' => \$validate,
'no-trim' => \$no_trim,
'no-scan' => \$no_scan,
'fs:s' => \$field_separator,
pod2usage(1) if $help;
-if ( $xlate ) {
- my @fields = split /,/, $xlate;
- $xlate = {};
- for my $field ( @fields ) {
- my ( $from, $to ) = split(/\//, $field);
- $xlate->{$from} = $to;
- }
-}
-
#
# If everything is OK, translate file(s).
#
my $translator = SQL::Translator->new(
- xlate => $xlate || {},
debug => $debug || 0,
trace => $trace || 0,
no_comments => $no_comments || 0,
show_warnings => $show_warnings || 0,
add_drop_table => $add_drop_table || 0,
+ validate => $validate || 0,
parser_args => {
trim_fields => $no_trim ? 0 : 1,
scan_fields => $no_scan ? 0 : 1,
Options:
-d|--debug Print debug info
+ -v|--validate Validate the schema
--trace Print parser trace info
--no-comments Don't include comments in SQL output
--show-warnings Print to STDERR warnings of conflicts, etc.