From: Chris Hilton Date: Wed, 10 Aug 2005 16:46:55 +0000 (+0000) Subject: Modified equals() to stringify field checks and use more case insensitivity when... X-Git-Tag: v0.11008~487 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=6be9534bf7091f6446c9a9ccf72c6fe4ac0ead19;p=dbsrgits%2FSQL-Translator.git Modified equals() to stringify field checks and use more case insensitivity when required --- diff --git a/lib/SQL/Translator/Schema/Index.pm b/lib/SQL/Translator/Schema/Index.pm index 78d9b2b..05e67cb 100644 --- a/lib/SQL/Translator/Schema/Index.pm +++ b/lib/SQL/Translator/Schema/Index.pm @@ -1,7 +1,7 @@ package SQL::Translator::Schema::Index; # ---------------------------------------------------------------------- -# $Id: Index.pm,v 1.13 2005-06-29 22:02:29 duality72 Exp $ +# $Id: Index.pm,v 1.14 2005-08-10 16:46:55 duality72 Exp $ # ---------------------------------------------------------------------- # Copyright (C) 2002-4 SQLFairy Authors # @@ -53,7 +53,7 @@ use base 'SQL::Translator::Schema::Object'; 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 %VALID_INDEX_TYPE = ( UNIQUE, 1, @@ -254,7 +254,9 @@ Determines if this index is the same as another # 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; return 0 unless $self->type eq $other->type; - return 0 unless $self->_compare_objects(scalar $self->fields, scalar $other->fields); + my $selfFields = join(":", $self->fields); + my $otherFields = join(":", $other->fields); + return 0 unless $case_insensitive ? uc($selfFields) eq uc($otherFields) : $selfFields eq $otherFields; return 0 unless $self->_compare_objects(scalar $self->options, scalar $other->options); return 0 unless $self->_compare_objects(scalar $self->extra, scalar $other->extra); return 1; diff --git a/lib/SQL/Translator/Schema/Trigger.pm b/lib/SQL/Translator/Schema/Trigger.pm index e93fc6b..f974e8c 100644 --- a/lib/SQL/Translator/Schema/Trigger.pm +++ b/lib/SQL/Translator/Schema/Trigger.pm @@ -1,7 +1,7 @@ package SQL::Translator::Schema::Trigger; # ---------------------------------------------------------------------- -# $Id: Trigger.pm,v 1.7 2005-06-29 22:02:29 duality72 Exp $ +# $Id: Trigger.pm,v 1.8 2005-08-10 16:46:55 duality72 Exp $ # ---------------------------------------------------------------------- # Copyright (C) 2002-4 SQLFairy Authors # @@ -54,7 +54,7 @@ use base 'SQL::Translator::Schema::Object'; use vars qw($VERSION $TABLE_COUNT $VIEW_COUNT); -$VERSION = sprintf "%d.%02d", q$Revision: 1.7 $ =~ /(\d+)\.(\d+)/; +$VERSION = sprintf "%d.%02d", q$Revision: 1.8 $ =~ /(\d+)\.(\d+)/; # ---------------------------------------------------------------------- @@ -321,9 +321,10 @@ Determines if this trigger is the same as another my $self = shift; my $other = shift; + my $case_insensitive = shift; return 0 unless $self->SUPER::equals($other); - return 0 unless $self->name eq $other->name; + 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; return 0 unless $self->perform_action_when eq $other->perform_action_when; return 0 unless $self->database_event eq $other->database_event; diff --git a/lib/SQL/Translator/Schema/View.pm b/lib/SQL/Translator/Schema/View.pm index 29364eb..2ad4bf9 100644 --- a/lib/SQL/Translator/Schema/View.pm +++ b/lib/SQL/Translator/Schema/View.pm @@ -1,7 +1,7 @@ package SQL::Translator::Schema::View; # ---------------------------------------------------------------------- -# $Id: View.pm,v 1.11 2005-06-29 22:02:29 duality72 Exp $ +# $Id: View.pm,v 1.12 2005-08-10 16:46:55 duality72 Exp $ # ---------------------------------------------------------------------- # Copyright (C) 2002-4 SQLFairy Authors # @@ -50,7 +50,7 @@ use base 'SQL::Translator::Schema::Object'; use vars qw($VERSION $TABLE_COUNT $VIEW_COUNT); -$VERSION = sprintf "%d.%02d", q$Revision: 1.11 $ =~ /(\d+)\.(\d+)/; +$VERSION = sprintf "%d.%02d", q$Revision: 1.12 $ =~ /(\d+)\.(\d+)/; # ---------------------------------------------------------------------- @@ -224,12 +224,15 @@ Determines if this view is the same as another my $self = shift; my $other = shift; + my $case_insensitive = shift; return 0 unless $self->SUPER::equals($other); - return 0 unless $self->name eq $other->name; + 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; return 0 unless $self->sql eq $other->sql; - return 0 unless $self->_compare_objects(scalar $self->fields, scalar $other->fields); + my $selfFields = join(":", $self->fields); + my $otherFields = join(":", $other->fields); + return 0 unless $case_insensitive ? uc($selfFields) eq uc($otherFields) : $selfFields eq $otherFields; return 0 unless $self->_compare_objects(scalar $self->extra, scalar $other->extra); return 1; }