Added options for ignoring the differences in SQL for views and procedures
[dbsrgits/SQL-Translator.git] / bin / sqlt-diff
index ee47c8b..5e8167b 100755 (executable)
@@ -2,7 +2,7 @@
 # vim: set ft=perl:
 
 # -------------------------------------------------------------------
-# $Id: sqlt-diff,v 1.17 2007-03-19 17:15:54 duality72 Exp $
+# $Id: sqlt-diff,v 1.18 2007-03-21 15:20:50 duality72 Exp $
 # -------------------------------------------------------------------
 # Copyright (C) 2002-4 The SQLFairy Authors
 #
@@ -51,6 +51,8 @@ Options:
   --output-db=<Producer>  This Producer will be used instead of one
                           corresponding to parser1 to format output
                           for new tables
+  --ignore-view-sql    Ignore view SQL differences
+  --ignore-proc-sql    Ignore procedure SQL differences
 
 =head1 DESCRIPTION
 
@@ -107,10 +109,11 @@ use SQL::Translator::Diff;
 use SQL::Translator::Schema::Constants;
 
 use vars qw( $VERSION );
-$VERSION = sprintf "%d.%02d", q$Revision: 1.17 $ =~ /(\d+)\.(\d+)/;
+$VERSION = sprintf "%d.%02d", q$Revision: 1.18 $ =~ /(\d+)\.(\d+)/;
 
-my ( @input, $list, $help, $debug, $trace, $caseopt,$ignore_index_names, 
-       $ignore_constraint_names, $output_db, $mysql_parser_version );
+my ( @input, $list, $help, $debug, $trace, $caseopt, $ignore_index_names, 
+       $ignore_constraint_names, $output_db, $mysql_parser_version,
+       $ignore_view_sql, $ignore_proc_sql );
 for my $arg ( @ARGV ) {
     if ( $arg =~ m/^-?-l(ist)?$/ ) {
         $list = 1;
@@ -139,6 +142,12 @@ for my $arg ( @ARGV ) {
     elsif ( $arg =~ m/^--output-db=(.+)$/ ) {
         $output_db = $1; 
     }
+    elsif ( $arg =~ m/^--ignore-view-sql$/ ) {
+        $ignore_view_sql = 1; 
+    }
+    elsif ( $arg =~ m/^--ignore-proc-sql$/ ) {
+        $ignore_proc_sql = 1; 
+    }
     elsif ( $arg =~ m/^([^=]+)=(.+)$/ ) {
         push @input, { file => $1, parser => $2 };
     }
@@ -169,7 +178,7 @@ my ( $source_schema, $source_db, $target_schema, $target_db ) = map {
     die "Unable to read file '$file'\n" unless -r $file;
     die "'$parser' is an invalid parser\n" unless $valid_parsers{ $parser };
 
-    my $t = SQL::Translator->new(parser_args => {mysql_parser_version => $mysql_parser_version || 0});
+    my $t = SQL::Translator->new(parser_args => {mysql_parser_version => $mysql_parser_version});
     $t->debug( $debug );
     $t->trace( $trace );
     $t->parser( $parser )            or die $tr->error;
@@ -187,6 +196,8 @@ my $result = SQL::Translator::Diff::schema_diff($source_schema, $source_db,
                                                 { caseopt                 => $caseopt,
                                                   ignore_index_names      => $ignore_index_names,
                                                   ignore_constraint_names => $ignore_constraint_names,
+                                                  ignore_view_sql         => $ignore_view_sql,
+                                                  ignore_proc_sql         => $ignore_proc_sql,
                                                   output_db               => $output_db,
                                                   debug                   => $debug,
                                                   trace                   => $trace });