Mercurial > pub > Impl
comparison Lib/IMPL/SQL/Schema/Constraint/PrimaryKey.pm @ 165:76515373dac0
Added Class::Template,
Rewritten SQL::Schema
'use parent' directive instead of 'use base'
| author | wizard |
|---|---|
| date | Sat, 23 Apr 2011 23:06:48 +0400 |
| parents | 16ada169ca75 |
| children | 6148f89bb7bf |
comparison
equal
deleted
inserted
replaced
| 164:eb3e9861a761 | 165:76515373dac0 |
|---|---|
| 1 package IMPL::SQL::Schema::Constraint::PrimaryKey; | 1 package IMPL::SQL::Schema::Constraint::PrimaryKey; |
| 2 use strict; | 2 use strict; |
| 3 use base qw(IMPL::SQL::Schema::Constraint::Index); | 3 use parent qw(IMPL::SQL::Schema::Constraint::Index); |
| 4 use IMPL::Class::Property; | 4 use IMPL::Class::Property; |
| 5 use IMPL::Class::Property::Direct; | 5 use IMPL::Class::Property::Direct; |
| 6 | 6 |
| 7 __PACKAGE__->PassThroughArgs; | 7 __PACKAGE__->PassThroughArgs; |
| 8 | 8 |
| 9 BEGIN { | 9 BEGIN { |
| 10 public _direct property ConnectedFK => prop_get; | 10 public _direct property connectedFK => prop_get; |
| 11 } | 11 } |
| 12 | 12 |
| 13 sub CTOR { | 13 sub CTOR { |
| 14 my ($this,%args) = @_; | 14 my ($this,%args) = @_; |
| 15 | 15 |
| 16 $this->SUPER::CTOR(%args); | 16 $this->{$connectedFK} = {}; |
| 17 | |
| 18 $this->{$ConnectedFK} = {}; | |
| 19 } | 17 } |
| 20 | 18 |
| 21 sub ConnectFK { | 19 sub ConnectFK { |
| 22 my ($this,$FK) = @_; | 20 my ($this,$FK) = @_; |
| 23 | 21 |
| 24 UNIVERSAL::isa($FK,'IMPL::SQL::Schema::Constraint::ForeignKey') or die new Exception('Aprimary key could be connected only to a foreign key'); | 22 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); | 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); |
| 26 | 24 |
| 27 $this->{$ConnectedFK}->{$FK->UniqName} = $FK; | 25 $this->{$connectedFK}->{$FK->uniqName} = $FK; |
| 28 } | 26 } |
| 29 | 27 |
| 30 sub DisconnectFK { | 28 sub DisconnectFK { |
| 31 my ($this,$FK) = @_; | 29 my ($this,$FK) = @_; |
| 32 | 30 |
| 33 delete $this->{$ConnectedFK}->{$FK->UniqName}; | 31 delete $this->{$connectedFK}->{$FK->uniqName}; |
| 34 } | 32 } |
| 35 | 33 |
| 36 sub Dispose { | 34 sub Dispose { |
| 37 my ($this) = @_; | 35 my ($this) = @_; |
| 38 | 36 |
| 39 delete $this->{$ConnectedFK}; | 37 delete $this->{$connectedFK}; |
| 38 | |
| 40 $this->SUPER::Dispose; | 39 $this->SUPER::Dispose; |
| 41 } | 40 } |
| 42 | 41 |
| 43 1; | 42 1; |
