comparison lib/IMPL/SQL/Schema/Constraint/PrimaryKey.pm @ 407:c6e90e02dd17 ref20150831

renamed Lib->lib
author cin
date Fri, 04 Sep 2015 19:40:23 +0300
parents
children
comparison
equal deleted inserted replaced
406:f23fcb19d3c1 407:c6e90e02dd17
1 package IMPL::SQL::Schema::Constraint::PrimaryKey;
2 use strict;
3 use parent qw(IMPL::SQL::Schema::Constraint::Index);
4 use IMPL::Class::Property;
5
6 __PACKAGE__->PassThroughArgs;
7 __PACKAGE__->RegisterAlias('pk');
8
9 BEGIN {
10 public _direct property connectedFK => prop_get;
11 }
12
13 sub CTOR {
14 my ($this,%args) = @_;
15
16 $this->{$connectedFK} = {};
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');
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);
24
25 $this->{$connectedFK}->{$FK->uniqName} = $FK;
26 }
27
28 sub DisconnectFK {
29 my ($this,$FK) = @_;
30
31 delete $this->{$connectedFK}->{$FK->uniqName};
32 }
33
34 sub Dispose {
35 my ($this) = @_;
36
37 delete $this->{$connectedFK};
38
39 $this->SUPER::Dispose;
40 }
41
42 1;