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