quiet noise
[DBIx-DBSchema.git] / DBSchema / ForeignKey.pm
index 282f8a3..8be4032 100644 (file)
@@ -2,7 +2,7 @@ package DBIx::DBSchema::ForeignKey;
 
 use strict;
 
-our $VERSION = '0.1';
+our $VERSION = '0.12';
 our $DEBUG = 0;
 
 =head1 NAME
@@ -20,7 +20,9 @@ DBIx::DBSchema::ForeignKey - Foreign key objects
   );
 
   $foreign_key = new DBIx::DBSchema::ForeignKey (
-    { 'columns'    => [ 'column_name', 'column2' ],
+    {
+      'constraint' => 'constraint_name',
+      'columns'    => [ 'column_name', 'column2' ],
       'table'      => 'foreign_table',
       'references' => [ 'foreign_column', 'foreign_column2' ],
       'match'      => 'MATCH FULL', # or MATCH SIMPLE
@@ -75,7 +77,7 @@ sub new {
 
 =item constraint [ CONSTRAINT_NAME ]
 
-Returns or sets the foreign table name
+Returns or sets the constraint name
 
 =cut
 
@@ -167,7 +169,7 @@ sub match {
   if ( defined($value) ) {
     $self->{match} = $value;
   } else {
-    $self->{match};
+    defined($self->{match}) ? $self->{match} : '';
   }
 }
 
@@ -182,7 +184,7 @@ sub on_delete {
   if ( defined($value) ) {
     $self->{on_delete} = $value;
   } else {
-    $self->{on_delete};
+    defined($self->{on_delete}) ? $self->{on_delete} : '';
   }
 }
 
@@ -197,12 +199,10 @@ sub on_update {
   if ( defined($value) ) {
     $self->{on_update} = $value;
   } else {
-    $self->{on_update};
+    defined($self->{on_update}) ? $self->{on_update} : '';
   }
 }
 
-
-
 =item sql_foreign_key
 
 Returns an SQL FOREIGN KEY statement.
@@ -231,8 +231,11 @@ sub cmp {
   my( $self, $other ) = @_;
 
   $self->table eq $other->table
-    and $self->columns_sql eq $other->columns_sql
+    and $self->columns_sql    eq $other->columns_sql
     and $self->references_sql eq $other->references_sql
+    and uc($self->match)      eq uc($other->match)
+    and uc($self->on_delete)  eq uc($other->on_delete)
+    and uc($self->on_update)  eq uc($other->on_update)
   ;
 }