From: Ken Youens-Clark Date: Wed, 15 Apr 2009 16:36:19 +0000 (+0000) Subject: Fixed up "equals" to be more informative when there's a problem. X-Git-Tag: v0.11008~202 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=7f275a619f7ac1b850a70c2695dde3fac84eb22c;p=dbsrgits%2FSQL-Translator.git Fixed up "equals" to be more informative when there's a problem. --- diff --git a/lib/SQL/Translator/Schema/Trigger.pm b/lib/SQL/Translator/Schema/Trigger.pm index 0f26325..dd63b4d 100644 --- a/lib/SQL/Translator/Schema/Trigger.pm +++ b/lib/SQL/Translator/Schema/Trigger.pm @@ -402,22 +402,39 @@ Determines if this trigger is the same as another 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 %names; + for my $name ( $self->name, $other->name ) { + $name = lc $name if $case_insensitive; + $names{ $name }++; + } - return 0 unless $self->perform_action_when eq $other->perform_action_when; + if ( keys %names > 1 ) { + return $self->error('Names not equal'); + } - return 0 - unless compare_arrays( $self->database_events, $other->database_events ); + if ( !$self->perform_action_when eq $other->perform_action_when ) { + return $self->error('perform_action_when differs'); + } + + if ( + !compare_arrays( [$self->database_events], [$other->database_events] ) + ) { + return $self->error('database_events differ'); + } - return 0 unless $self->on_table eq $other->on_table; + if ( $self->on_table ne $other->on_table ) { + return $self->error('on_table differs'); + } - return 0 unless $self->action eq $other->action; + if ( $self->action ne $other->action ) { + return $self->error('action differs'); + } - return 0 unless $self->_compare_objects( scalar $self->extra, - scalar $other->extra ); + if ( + !$self->_compare_objects( scalar $self->extra, scalar $other->extra ) + ) { + return $self->error('extras differ'); + } return 1; }