Mercurial > pub > Impl
comparison Lib/IMPL/SQL/Schema/Constraint/ForeignKey.pm @ 33:0004faa276dc
small fixes, some new tests
author | Sergey |
---|---|
date | Mon, 09 Nov 2009 16:49:39 +0300 |
parents | 56cef8e3cda6 |
children | 16ada169ca75 |
comparison
equal
deleted
inserted
replaced
32:56cef8e3cda6 | 33:0004faa276dc |
---|---|
23 my $ForeingPK = $args{'ReferencedTable'}->PrimaryKey or die new Exception('The referenced table doesn\'t have a primary key'); | 23 my $ForeingPK = $args{'ReferencedTable'}->PrimaryKey or die new Exception('The referenced table doesn\'t have a primary key'); |
24 | 24 |
25 scalar (@ReferencedColumns) == scalar(@{$this->Columns}) or die new Exception('A foreing key columns doesn\'t match refenced columns'); | 25 scalar (@ReferencedColumns) == scalar(@{$this->Columns}) or die new Exception('A foreing key columns doesn\'t match refenced columns'); |
26 my @ColumnsCopy = @ReferencedColumns; | 26 my @ColumnsCopy = @ReferencedColumns; |
27 | 27 |
28 die new Exception('A foreing key columns doesn\'t match refenced columns') if grep { not $_->Type->isSame((shift @ColumnsCopy)->Type)} $this->Columns; | 28 die new Exception('A foreing key columns doesn\'t match refenced columns') if grep { not $_->Type->isSame((shift @ColumnsCopy)->Type)} @{$this->Columns}; |
29 | 29 |
30 @ColumnsCopy = @ReferencedColumns; | 30 @ColumnsCopy = @ReferencedColumns; |
31 die new Exception('The foreign key must match to the primary key of the referenced table',$this->Name) if grep { not $_->Type->isSame(shift(@ColumnsCopy)->Type)} $ForeingPK->Columns; | 31 die new Exception('The foreign key must match to the primary key of the referenced table',$this->Name) if grep { not $_->Type->isSame(shift(@ColumnsCopy)->Type)} @{$ForeingPK->Columns}; |
32 | 32 |
33 $this->{$ReferencedPrimaryKey} = $ForeingPK; | 33 $this->{$ReferencedPrimaryKey} = $ForeingPK; |
34 | 34 |
35 $ForeingPK->ConnectFK($this); | 35 $ForeingPK->ConnectFK($this); |
36 } | 36 } |
37 | 37 |
38 sub Dispose { | 38 sub Dispose { |
39 my ($this) = @_; | 39 my ($this) = @_; |
40 | 40 |
41 $this->{$ReferencedPrimaryKey}->DisconnectFK($this) if not $this->{$ReferencedPrimaryKey}->isa('Object::Disposed'); | 41 $this->{$ReferencedPrimaryKey}->DisconnectFK($this) if not $this->{$ReferencedPrimaryKey}->isDisposed; |
42 delete $this->{$ReferencedPrimaryKey}; | 42 delete $this->{$ReferencedPrimaryKey}; |
43 | 43 |
44 $this->SUPER::Dispose; | 44 $this->SUPER::Dispose; |
45 } | 45 } |
46 | 46 |