32
|
1 package IMPL::SQL::Schema::Constraint::PrimaryKey;
|
|
2 use strict;
|
|
3 use base qw(IMPL::SQL::Schema::Constraint::Index);
|
|
4 use IMPL::Class::Property;
|
|
5 use IMPL::Class::Property::Direct;
|
|
6
|
|
7 __PACKAGE__->PassThroughArgs;
|
|
8
|
|
9 BEGIN {
|
|
10 public _direct property ConnectedFK => prop_get;
|
|
11 }
|
|
12
|
|
13 sub CTOR {
|
|
14 my ($this,%args) = @_;
|
|
15
|
|
16 $this->SUPER::CTOR(%args);
|
|
17
|
|
18 $this->{$ConnectedFK} = {};
|
|
19 }
|
|
20
|
|
21 sub ConnectFK {
|
|
22 my ($this,$FK) = @_;
|
|
23
|
|
24 UNIVERSAL::isa($FK,'IMPL::SQL::Schema::Constraint::ForeignKey') or die new Exception('Aprimary key could be connected only to a foreign key');
|
|
25 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);
|
|
26
|
|
27 $this->{$ConnectedFK}->{$FK->UniqName} = $FK;
|
|
28 }
|
|
29
|
|
30 sub DisconnectFK {
|
|
31 my ($this,$FK) = @_;
|
|
32
|
|
33 delete $this->{$ConnectedFK}->{$FK->UniqName};
|
|
34 }
|
|
35
|
|
36 sub Dispose {
|
|
37 my ($this) = @_;
|
|
38
|
|
39 delete $this->{$ConnectedFK};
|
|
40 $this->SUPER::Dispose;
|
|
41 }
|
|
42
|
|
43 1; |