From: Ricardo Signes Date: Tue, 2 Dec 2008 20:18:20 +0000 (+0000) Subject: properly compare fields X-Git-Tag: v0.11008~271 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=f5fd433f1b17eaf0d0904f0fd486c92772d07a56;p=dbsrgits%2FSQL-Translator.git properly compare fields --- diff --git a/lib/SQL/Translator/Schema/Field.pm b/lib/SQL/Translator/Schema/Field.pm index 93d25e2..346ab16 100644 --- a/lib/SQL/Translator/Schema/Field.pm +++ b/lib/SQL/Translator/Schema/Field.pm @@ -644,8 +644,25 @@ Determines if this field is the same as another } return 0 unless $self->size eq $other->size; - return 0 unless (!defined $self->default_value || $self->default_value eq 'NULL') eq (!defined $other->default_value || $other->default_value eq 'NULL'); - return 0 if defined $self->default_value && $self->default_value ne $other->default_value; + + { + my $lhs = $self->default_value; + $lhs = \'NULL' unless defined $lhs; + my $lhs_is_ref = ! ! ref $lhs; + + my $rhs = $other->default_value; + $rhs = \'NULL' unless defined $rhs; + my $rhs_is_ref = ! ! ref $rhs; + + # If only one is a ref, fail. -- rjbs, 2008-12-02 + return 0 if $lhs_is_ref xor $rhs_is_ref; + + my $effective_lhs = $lhs_is_ref ? $$lhs : $lhs; + my $effective_rhs = $rhs_is_ref ? $$rhs : $rhs; + + return 0 if $effective_lhs ne $effective_rhs; + } + return 0 unless $self->is_nullable eq $other->is_nullable; # return 0 unless $self->is_unique eq $other->is_unique; return 0 unless $self->is_primary_key eq $other->is_primary_key;