From: Chris Hilton Date: Wed, 10 Aug 2005 16:42:47 +0000 (+0000) Subject: Modified equals() to include type check, stringify field checks, and more case insens... X-Git-Tag: v0.11008~490 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=b8d244857b86f8e98634a8239e36d9dbe44b10d8;p=dbsrgits%2FSQL-Translator.git Modified equals() to include type check, stringify field checks, and more case insensitivity when required --- diff --git a/lib/SQL/Translator/Schema/Constraint.pm b/lib/SQL/Translator/Schema/Constraint.pm index e601947..a8133b3 100644 --- a/lib/SQL/Translator/Schema/Constraint.pm +++ b/lib/SQL/Translator/Schema/Constraint.pm @@ -1,7 +1,7 @@ package SQL::Translator::Schema::Constraint; # ---------------------------------------------------------------------- -# $Id: Constraint.pm,v 1.18 2005-06-29 22:02:17 duality72 Exp $ +# $Id: Constraint.pm,v 1.19 2005-08-10 16:42:47 duality72 Exp $ # ---------------------------------------------------------------------- # Copyright (C) 2002-4 SQLFairy Authors # @@ -51,7 +51,7 @@ use base 'SQL::Translator::Schema::Object'; use vars qw($VERSION $TABLE_COUNT $VIEW_COUNT); -$VERSION = sprintf "%d.%02d", q$Revision: 1.18 $ =~ /(\d+)\.(\d+)/; +$VERSION = sprintf "%d.%02d", q$Revision: 1.19 $ =~ /(\d+)\.(\d+)/; my %VALID_CONSTRAINT_TYPE = ( PRIMARY_KEY, 1, @@ -541,15 +541,20 @@ Determines if this constraint is the same as another my $case_insensitive = shift; return 0 unless $self->SUPER::equals($other); + return 0 unless $self->type eq $other->type; return 0 unless $case_insensitive ? uc($self->name) eq uc($other->name) : $self->name eq $other->name; return 0 unless $self->deferrable eq $other->deferrable; #return 0 unless $self->is_valid eq $other->is_valid; return 0 unless $case_insensitive ? uc($self->table->name) eq uc($other->table->name) : $self->table->name eq $other->table->name; return 0 unless $self->expression eq $other->expression; - return 0 unless $self->_compare_objects(scalar $self->field_names, scalar $other->field_names); - return 0 unless $self->reference_table eq $other->reference_table; - return 0 unless $self->_compare_objects(scalar $self->reference_fields, scalar $other->reference_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 $case_insensitive ? uc($self->reference_table) eq uc($other->reference_table) : $self->reference_table eq $other->reference_table; + my $selfRefFields = join(":", $self->reference_fields); + my $otherRefFields = join(":", $other->reference_fields); + return 0 unless $case_insensitive ? uc($selfRefFields) eq uc($otherRefFields) : $selfRefFields eq $otherRefFields; return 0 unless $self->match_type eq $other->match_type; return 0 unless $self->on_delete eq $other->on_delete; return 0 unless $self->on_update eq $other->on_update;