annotate Lib/Schema/DB/Column.pm @ 23:716b287d4795

merge
author Sergey
date Wed, 30 Sep 2009 17:43:52 +0400
parents 03e58a454b20
children 16ada169ca75
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
1 package Schema::DB::Column;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
2 use Common;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
3 our @ISA = qw(Object);
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
4
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
5 BEGIN {
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
6 DeclareProperty Name => ACCESS_READ;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
7 DeclareProperty Type => ACCESS_READ;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
8 DeclareProperty CanBeNull => ACCESS_READ;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
9 DeclareProperty DefaultValue => ACCESS_READ;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
10 DeclareProperty Tag => ACCESS_READ;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
11 }
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
12
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
13 sub CTOR {
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
14 my $this = shift;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
15 $this->SUPER::CTOR(@_);
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
16
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
17 $this->{$Name} or die new Exception('a column name is required');
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
18 $this->{$CanBeNull} = 0 if not exists $this->{$CanBeNull};
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
19 UNIVERSAL::isa($this->{$Type},'Schema::DB::Type') or die new Exception('a type is required for the column',$this->{$Name});
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
20 }
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
21
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
22 sub isEqualsStr {
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
23 my ($a,$b) = @_;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
24
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
25 if (defined $a and defined $b) {
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
26 return $a eq $b;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
27 } else {
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
28 if (defined $a or defined $b) {
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
29 return 0;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
30 } else {
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
31 return 1;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
32 }
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
33 }
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
34 }
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
35
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
36 sub isEquals {
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
37 my ($a,$b) = @_;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
38
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
39 if (defined $a and defined $b) {
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
40 return $a == $b;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
41 } else {
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
42 if (defined $a or defined $b) {
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
43 return 0;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
44 } else {
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
45 return 1;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
46 }
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
47 }
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
48 }
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
49
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
50 sub isSame {
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
51 my ($this,$other) = @_;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
52
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
53 return ($this->{$Name} eq $other->{$Name} and $this->{$CanBeNull} == $other->{$CanBeNull} and isEqualsStr($this->{$DefaultValue}, $other->{$DefaultValue}) and $this->{$Type}->isSame($other->{$Type}));
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
54 }
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
55
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
56 1;