annotate Lib/IMPL/SQL/Schema/Constraint/PrimaryKey.pm @ 167:1f7a6d762394

SQL schema in progress
author sourcer
date Thu, 12 May 2011 08:57:19 +0400
parents 76515373dac0
children 6148f89bb7bf
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
1 package IMPL::SQL::Schema::Constraint::PrimaryKey;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
2 use strict;
165
76515373dac0 Added Class::Template,
wizard
parents: 49
diff changeset
3 use parent qw(IMPL::SQL::Schema::Constraint::Index);
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
4 use IMPL::Class::Property;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
5 use IMPL::Class::Property::Direct;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
6
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
7 __PACKAGE__->PassThroughArgs;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
8
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
9 BEGIN {
165
76515373dac0 Added Class::Template,
wizard
parents: 49
diff changeset
10 public _direct property connectedFK => prop_get;
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
11 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
12
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
13 sub CTOR {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
14 my ($this,%args) = @_;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
15
165
76515373dac0 Added Class::Template,
wizard
parents: 49
diff changeset
16 $this->{$connectedFK} = {};
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
17 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
18
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
19 sub ConnectFK {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
20 my ($this,$FK) = @_;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
21
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
22 UNIVERSAL::isa($FK,'IMPL::SQL::Schema::Constraint::ForeignKey') or die new Exception('Aprimary key could be connected only to a foreign key');
165
76515373dac0 Added Class::Template,
wizard
parents: 49
diff changeset
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
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
24
165
76515373dac0 Added Class::Template,
wizard
parents: 49
diff changeset
25 $this->{$connectedFK}->{$FK->uniqName} = $FK;
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
26 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
27
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
28 sub DisconnectFK {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
29 my ($this,$FK) = @_;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
30
165
76515373dac0 Added Class::Template,
wizard
parents: 49
diff changeset
31 delete $this->{$connectedFK}->{$FK->uniqName};
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
32 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
33
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
34 sub Dispose {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
35 my ($this) = @_;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
36
165
76515373dac0 Added Class::Template,
wizard
parents: 49
diff changeset
37 delete $this->{$connectedFK};
76515373dac0 Added Class::Template,
wizard
parents: 49
diff changeset
38
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
39 $this->SUPER::Dispose;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
40 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
41
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
42 1;