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