# 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
#
--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
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;
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 };
}
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;
{ 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 });
my $trace = $options->{trace} || 0;
my $ignore_index_names = $options->{ignore_index_names} || 0;
my $ignore_constraint_names = $options->{ignore_constraint_names} || 0;
+ my $ignore_view_sql = $options->{ignore_view_sql} || 0;
+ my $ignore_proc_sql = $options->{ignore_proc_sql} || 0;
my $output_db = $options->{output_db} || $source_db;
my $tar_name = $target_schema->name;
PROC:
for my $p_tar ( $target_schema->get_procedures ) {
for my $p_src ( $source_schema->get_procedures ) {
- if ( $p_tar->equals($p_src, $case_insensitive) ) {
+ if ( $p_tar->equals($p_src, $case_insensitive, $ignore_proc_sql) ) {
$checked_procs{$p_src} = 1;
next PROC;
}
for my $p_src ( $source_schema->get_procedures ) {
next if $checked_procs{$p_src};
for my $p_tar ( $target_schema->get_procedures ) {
- next PROC2 if $p_src->equals($p_tar, $case_insensitive);
+ next PROC2 if $p_src->equals($p_tar, $case_insensitive, $ignore_proc_sql);
}
my $proc_ident = $p_src->owner ? sprintf("[%s].%s", $p_src->owner, $p_src->name) : $p_src->name;
push @diffs_proc_drops, "DROP PROCEDURE $proc_ident;\nGO\n";
VIEW:
for my $v_tar ( $target_schema->get_views ) {
for my $v_src ( $source_schema->get_views ) {
- if ( $v_tar->equals($v_src, $case_insensitive) ) {
+ if ( $v_tar->equals($v_src, $case_insensitive, $ignore_view_sql) ) {
$checked_views{$v_src} = 1;
next VIEW;
}
for my $v_src ( $source_schema->get_views ) {
next if $checked_views{$v_src};
for my $v_tar ( $target_schema->get_views ) {
- next VIEW2 if $v_src->equals($v_tar, $case_insensitive);
+ next VIEW2 if $v_src->equals($v_tar, $case_insensitive, $ignore_view_sql);
}
my $view_ident = $v_src->name;
push @diffs_view_drops, "DROP VIEW $view_ident;\nGO\n";
package SQL::Translator::Schema::Procedure;
# ----------------------------------------------------------------------
-# $Id: Procedure.pm,v 1.7 2007-03-14 20:22:58 duality72 Exp $
+# $Id: Procedure.pm,v 1.8 2007-03-21 15:20:50 duality72 Exp $
# ----------------------------------------------------------------------
# Copyright (C) 2002-4 SQLFairy Authors
#
use vars qw($VERSION);
-$VERSION = sprintf "%d.%02d", q$Revision: 1.7 $ =~ /(\d+)\.(\d+)/;
+$VERSION = sprintf "%d.%02d", q$Revision: 1.8 $ =~ /(\d+)\.(\d+)/;
# ----------------------------------------------------------------------
my $self = shift;
my $other = shift;
my $case_insensitive = shift;
+ my $ignore_sql = shift;
return 0 unless $self->SUPER::equals($other);
return 0 unless $case_insensitive ? uc($self->name) eq uc($other->name) : $self->name eq $other->name;
- my $selfSql = $self->sql;
- my $otherSql = $other->sql;
- # Remove comments
- $selfSql =~ s/--.*$//mg;
- $otherSql =~ s/--.*$//mg;
- # Collapse whitespace to space to avoid whitespace comparison issues
- $selfSql =~ s/\s+/ /sg;
- $otherSql =~ s/\s+/ /sg;
- return 0 unless $selfSql eq $otherSql;
+ unless ($ignore_sql) {
+ my $selfSql = $self->sql;
+ my $otherSql = $other->sql;
+ # Remove comments
+ $selfSql =~ s/--.*$//mg;
+ $otherSql =~ s/--.*$//mg;
+ # Collapse whitespace to space to avoid whitespace comparison issues
+ $selfSql =~ s/\s+/ /sg;
+ $otherSql =~ s/\s+/ /sg;
+ return 0 unless $selfSql eq $otherSql;
+ }
return 0 unless $self->_compare_objects(scalar $self->parameters, scalar $other->parameters);
# return 0 unless $self->comments eq $other->comments;
- return 0 unless $case_insensitive ? uc($self->owner) eq uc($other->owner) : $self->owner eq $other->owner;
+# return 0 unless $case_insensitive ? uc($self->owner) eq uc($other->owner) : $self->owner eq $other->owner;
return 0 unless $self->_compare_objects(scalar $self->extra, scalar $other->extra);
return 1;
}
package SQL::Translator::Schema::View;
# ----------------------------------------------------------------------
-# $Id: View.pm,v 1.13 2007-03-14 20:22:58 duality72 Exp $
+# $Id: View.pm,v 1.14 2007-03-21 15:20:50 duality72 Exp $
# ----------------------------------------------------------------------
# Copyright (C) 2002-4 SQLFairy Authors
#
use vars qw($VERSION $TABLE_COUNT $VIEW_COUNT);
-$VERSION = sprintf "%d.%02d", q$Revision: 1.13 $ =~ /(\d+)\.(\d+)/;
+$VERSION = sprintf "%d.%02d", q$Revision: 1.14 $ =~ /(\d+)\.(\d+)/;
# ----------------------------------------------------------------------
my $self = shift;
my $other = shift;
my $case_insensitive = shift;
+ my $ignore_sql = shift;
return 0 unless $self->SUPER::equals($other);
return 0 unless $case_insensitive ? uc($self->name) eq uc($other->name) : $self->name eq $other->name;
#return 0 unless $self->is_valid eq $other->is_valid;
- my $selfSql = $self->sql;
- my $otherSql = $other->sql;
- # Remove comments
- $selfSql =~ s/--.*$//mg;
- $otherSql =~ s/--.*$//mg;
- # Collapse whitespace to space to avoid whitespace comparison issues
- $selfSql =~ s/\s+/ /sg;
- $otherSql =~ s/\s+/ /sg;
- return 0 unless $selfSql eq $otherSql;
+ unless ($ignore_sql) {
+ my $selfSql = $self->sql;
+ my $otherSql = $other->sql;
+ # Remove comments
+ $selfSql =~ s/--.*$//mg;
+ $otherSql =~ s/--.*$//mg;
+ # Collapse whitespace to space to avoid whitespace comparison issues
+ $selfSql =~ s/\s+/ /sg;
+ $otherSql =~ s/\s+/ /sg;
+ return 0 unless $selfSql eq $otherSql;
+ }
my $selfFields = join(":", $self->fields);
my $otherFields = join(":", $other->fields);