package SQL::Translator::Schema::Constraint;
# ----------------------------------------------------------------------
-# $Id: Constraint.pm,v 1.15 2004-11-05 13:19:31 grommit Exp $
+# $Id: Constraint.pm,v 1.16 2005-06-27 21:59:19 duality72 Exp $
# ----------------------------------------------------------------------
# Copyright (C) 2002-4 SQLFairy Authors
#
use vars qw($VERSION $TABLE_COUNT $VIEW_COUNT);
-$VERSION = sprintf "%d.%02d", q$Revision: 1.15 $ =~ /(\d+)\.(\d+)/;
+$VERSION = sprintf "%d.%02d", q$Revision: 1.16 $ =~ /(\d+)\.(\d+)/;
my %VALID_CONSTRAINT_TYPE = (
PRIMARY_KEY, 1,
return $self->{'type'} || '';
}
+
+# ----------------------------------------------------------------------
+sub equals {
+
+=pod
+
+=head2 equals
+
+Determines if this constraint is the same as another
+
+ my $isIdentical = $constraint1->equals( $constraint2 );
+
+=cut
+
+ my $self = shift;
+ my $other = shift;
+ my $case_insensitive = 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->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($self->fields, $other->fields);
+ return 0 unless $self->reference_table eq $other->reference_table;
+ return 0 unless $self->_compare_objects($self->reference_fields, $other->reference_fields);
+ 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;
+ return 0 unless $self->_compare_objects($self->options, $other->options);
+ return 0 unless $self->_compare_objects($self->extra, $other->extra);
+ return 1;
+}
+
# ----------------------------------------------------------------------
sub DESTROY {
my $self = shift;
package SQL::Translator::Schema::Field;
# ----------------------------------------------------------------------
-# $Id: Field.pm,v 1.22 2004-11-05 15:03:10 grommit Exp $
+# $Id: Field.pm,v 1.23 2005-06-27 21:59:19 duality72 Exp $
# ----------------------------------------------------------------------
# Copyright (C) 2002-4 SQLFairy Authors
#
use vars qw($VERSION $TABLE_COUNT $VIEW_COUNT);
-$VERSION = sprintf "%d.%02d", q$Revision: 1.22 $ =~ /(\d+)\.(\d+)/;
+$VERSION = sprintf "%d.%02d", q$Revision: 1.23 $ =~ /(\d+)\.(\d+)/;
# Stringify to our name, being careful not to pass any args through so we don't
# accidentally set it to undef. We also have to tweak bool so the object is
}
# ----------------------------------------------------------------------
+sub equals {
+
+=pod
+
+=head2 equals
+
+Determines if this field is the same as another
+
+ my $isIdentical = $field1->equals( $field2 );
+
+=cut
+
+ my $self = shift;
+ my $other = shift;
+ my $case_insensitive = 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;
+ return 0 unless $self->data_type eq $other->data_type;
+ return 0 unless $self->size eq $other->size;
+ return 0 unless defined $self->default_value eq defined $other->default_value;
+ return 0 if defined $self->default_value && $self->default_value ne $other->default_value;
+ 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;
+ return 0 unless $self->is_foreign_key eq $other->is_foreign_key;
+ return 0 unless $self->is_auto_increment eq $other->is_auto_increment;
+# return 0 unless $self->comments eq $other->comments;
+ return 0 unless $self->_compare_objects($self->extra, $other->extra);
+ return 1;
+}
+
+# ----------------------------------------------------------------------
sub DESTROY {
#
# Destroy cyclical references.
package SQL::Translator::Schema::Index;
# ----------------------------------------------------------------------
-# $Id: Index.pm,v 1.10 2004-11-05 13:19:31 grommit Exp $
+# $Id: Index.pm,v 1.11 2005-06-27 21:59:19 duality72 Exp $
# ----------------------------------------------------------------------
# Copyright (C) 2002-4 SQLFairy Authors
#
use vars qw($VERSION $TABLE_COUNT $VIEW_COUNT);
-$VERSION = sprintf "%d.%02d", q$Revision: 1.10 $ =~ /(\d+)\.(\d+)/;
+$VERSION = sprintf "%d.%02d", q$Revision: 1.11 $ =~ /(\d+)\.(\d+)/;
my %VALID_INDEX_TYPE = (
UNIQUE, 1,
return $self->{'type'} || NORMAL;
}
+# ----------------------------------------------------------------------
+sub equals {
+
+=pod
+
+=head2 equals
+
+Determines if this index is the same as another
+
+ my $isIdentical = $index1->equals( $index2 );
+
+=cut
+
+ my $self = shift;
+ my $other = shift;
+ my $case_insensitive = 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;
+ return 0 unless $self->type eq $other->type;
+ return 0 unless $self->_compare_objects($self->fields, $other->fields);
+ return 0 unless $self->_compare_objects($self->options, $other->options);
+ return 0 unless $self->_compare_objects($self->extra, $other->extra);
+ return 1;
+}
# ----------------------------------------------------------------------
sub DESTROY {
package SQL::Translator::Schema::Procedure;
# ----------------------------------------------------------------------
-# $Id: Procedure.pm,v 1.4 2004-11-05 13:19:31 grommit Exp $
+# $Id: Procedure.pm,v 1.5 2005-06-27 21:59:20 duality72 Exp $
# ----------------------------------------------------------------------
# Copyright (C) 2002-4 SQLFairy Authors
#
use vars qw($VERSION);
-$VERSION = sprintf "%d.%02d", q$Revision: 1.4 $ =~ /(\d+)\.(\d+)/;
+$VERSION = sprintf "%d.%02d", q$Revision: 1.5 $ =~ /(\d+)\.(\d+)/;
# ----------------------------------------------------------------------
}
# ----------------------------------------------------------------------
+sub equals {
+
+=pod
+
+=head2 equals
+
+Determines if this procedure is the same as another
+
+ my $isIdentical = $procedure1->equals( $procedure2 );
+
+=cut
+
+ my $self = shift;
+ my $other = shift;
+
+ return 0 unless $self->SUPER::equals($other);
+ return 0 unless $self->name eq $other->name;
+ return 0 unless $self->sql eq $other->sql;
+ return 0 unless $self->_compare_objects($self->parameters, $other->parameters);
+# return 0 unless $self->comments eq $other->comments;
+ return 0 unless $self->owner eq $other->owner;
+ return 0 unless $self->_compare_objects($self->extra, $other->extra);
+ return 1;
+}
+
+# ----------------------------------------------------------------------
sub DESTROY {
my $self = shift;
undef $self->{'schema'}; # destroy cyclical reference
package SQL::Translator::Schema::Table;
# ----------------------------------------------------------------------
-# $Id: Table.pm,v 1.30 2004-11-27 16:32:46 schiffbruechige Exp $
+# $Id: Table.pm,v 1.31 2005-06-27 21:59:20 duality72 Exp $
# ----------------------------------------------------------------------
# Copyright (C) 2002-4 SQLFairy Authors
#
use vars qw( $VERSION $FIELD_ORDER );
-$VERSION = sprintf "%d.%02d", q$Revision: 1.30 $ =~ /(\d+)\.(\d+)/;
+$VERSION = sprintf "%d.%02d", q$Revision: 1.31 $ =~ /(\d+)\.(\d+)/;
# Stringify to our name, being careful not to pass any args through so we don't
}
# ----------------------------------------------------------------------
+sub equals {
+
+=pod
+
+=head2 equals
+
+Determines if this table is the same as another
+
+ my $isIdentical = $table1->equals( $table2 );
+
+=cut
+
+ my $self = shift;
+ my $other = shift;
+
+ return 0 unless $self->SUPER::equals($other);
+ return 0 unless $self->name eq $other->name;
+ return 0 unless $self->_compare_objects($self->options, $other->options);
+ return 0 unless $self->_compare_objects($self->extra, $other->extra);
+
+ # Fields
+ # Go through our fields
+ my %checkedFields;
+ foreach my $field ( $self->get_fields ) {
+ my $otherField = $other->get_field($field->name);
+ return 0 unless $field->equals($otherField);
+ $checkedFields{$field->name} = 1;
+ }
+ # Go through the other table's fields
+ foreach my $otherField ( $other->get_fields ) {
+ next if $checkedFields{$otherField->name};
+ return 0;
+ }
+
+ # Constraints
+ # Go through our constraints
+ my %checkedConstraints;
+CONSTRAINT:
+ foreach my $constraint ( $self->get_constraints ) {
+ foreach my $otherConstraint ( $other->get_constraints ) {
+ if ( $constraint->equals($otherConstraint) ) {
+ $checkedConstraints{$otherConstraint} = 1;
+ next CONSTRAINT;
+ }
+ }
+ return 0;
+ }
+ # Go through the other table's constraints
+ foreach my $otherConstraint ( $other->get_constraints ) {
+ next if $checkedFields{$otherConstraint};
+ return 0;
+ }
+
+ # Indices
+ # Go through our indices
+ my %checkedIndices;
+INDEX:
+ foreach my $index ( $self->get_indices ) {
+ foreach my $otherIndex ( $other->get_indices ) {
+ if ( $index->equals($otherIndex) ) {
+ $checkedIndices{$otherIndex} = 1;
+ next INDEX;
+ }
+ }
+ return 0;
+ }
+ # Go through the other table's constraints
+ foreach my $otherIndex ( $other->get_indices ) {
+ next if $checkedIndices{$otherIndex};
+ return 0;
+ }
+
+ return 1;
+}
+
+# ----------------------------------------------------------------------
=head1 LOOKUP METHODS
package SQL::Translator::Schema::Trigger;
# ----------------------------------------------------------------------
-# $Id: Trigger.pm,v 1.5 2004-11-05 13:19:31 grommit Exp $
+# $Id: Trigger.pm,v 1.6 2005-06-27 21:59:20 duality72 Exp $
# ----------------------------------------------------------------------
# Copyright (C) 2002-4 SQLFairy Authors
#
use vars qw($VERSION $TABLE_COUNT $VIEW_COUNT);
-$VERSION = sprintf "%d.%02d", q$Revision: 1.5 $ =~ /(\d+)\.(\d+)/;
+$VERSION = sprintf "%d.%02d", q$Revision: 1.6 $ =~ /(\d+)\.(\d+)/;
# ----------------------------------------------------------------------
}
# ----------------------------------------------------------------------
+sub equals {
+
+=pod
+
+=head2 equals
+
+Determines if this trigger is the same as another
+
+ my $isIdentical = $trigger1->equals( $trigger2 );
+
+=cut
+
+ my $self = shift;
+ my $other = shift;
+
+ return 0 unless $self->SUPER::equals($other);
+ return 0 unless $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;
+ return 0 unless $self->on_table eq $other->on_table;
+ return 0 unless $self->action eq $other->action;
+ return 0 unless $self->_compare_objects($self->extra, $other->extra);
+ return 1;
+}
+
+# ----------------------------------------------------------------------
sub DESTROY {
my $self = shift;
undef $self->{'schema'}; # destroy cyclical reference
package SQL::Translator::Schema::View;
# ----------------------------------------------------------------------
-# $Id: View.pm,v 1.9 2004-11-05 13:19:31 grommit Exp $
+# $Id: View.pm,v 1.10 2005-06-27 21:59:20 duality72 Exp $
# ----------------------------------------------------------------------
# Copyright (C) 2002-4 SQLFairy Authors
#
use vars qw($VERSION $TABLE_COUNT $VIEW_COUNT);
-$VERSION = sprintf "%d.%02d", q$Revision: 1.9 $ =~ /(\d+)\.(\d+)/;
+$VERSION = sprintf "%d.%02d", q$Revision: 1.10 $ =~ /(\d+)\.(\d+)/;
# ----------------------------------------------------------------------
}
# ----------------------------------------------------------------------
+sub equals {
+
+=pod
+
+=head2 equals
+
+Determines if this view is the same as another
+
+ my $isIdentical = $view1->equals( $view2 );
+
+=cut
+
+ my $self = shift;
+ my $other = shift;
+
+ return 0 unless $self->SUPER::equals($other);
+ return 0 unless $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($self->fields, $other->fields);
+ return 0 unless $self->_compare_objects($self->extra, $other->extra);
+ return 1;
+}
+
+# ----------------------------------------------------------------------
sub DESTROY {
my $self = shift;
undef $self->{'schema'}; # destroy cyclical reference