0
|
1 package Schema::DB::Constraint::PrimaryKey;
|
|
2 use strict;
|
|
3 use Common;
|
|
4 use base qw(Schema::DB::Constraint::Index);
|
|
5
|
|
6 BEGIN {
|
|
7 DeclareProperty ConnectedFK => ACCESS_READ;
|
|
8 }
|
|
9
|
|
10 sub CTOR {
|
|
11 my ($this,%args) = @_;
|
|
12
|
|
13 $this->SUPER::CTOR(%args);
|
|
14
|
|
15 $this->{$ConnectedFK} = {};
|
|
16 }
|
|
17
|
|
18 sub ConnectFK {
|
|
19 my ($this,$FK) = @_;
|
|
20
|
|
21 UNIVERSAL::isa($FK,'Schema::DB::Constraint::ForeignKey') or die new Exception('Aprimary key could be connected only to a foreign key');
|
|
22 not exists $this->{$ConnectedFK}->{$FK->UniqName} or die new Exception('This primary key already conneted with the specified foreing key',$FK->Name,$FK->Table->Name);
|
|
23
|
|
24 $this->{$ConnectedFK}->{$FK->UniqName} = $FK;
|
|
25 }
|
|
26
|
|
27 sub DisconnectFK {
|
|
28 my ($this,$FK) = @_;
|
|
29
|
|
30 delete $this->{$ConnectedFK}->{$FK->UniqName};
|
|
31 }
|
|
32
|
|
33 sub Dispose {
|
|
34 my ($this) = @_;
|
|
35
|
|
36 delete $this->{$ConnectedFK};
|
|
37 $this->SUPER::Dispose;
|
|
38 }
|
|
39
|
|
40 1; |