Mercurial > pub > Impl
comparison Lib/IMPL/SQL/Schema/Column.pm @ 32:56cef8e3cda6
+1
author | Sergey |
---|---|
date | Mon, 09 Nov 2009 01:39:31 +0300 |
parents | |
children | 16ada169ca75 |
comparison
equal
deleted
inserted
replaced
31:d59526f6310e | 32:56cef8e3cda6 |
---|---|
1 use strict; | |
2 package IMPL::SQL::Schema::Column; | |
3 use base qw(IMPL::Object IMPL::Object::Autofill); | |
4 | |
5 use IMPL::Class::Property; | |
6 use IMPL::Class::Property::Direct; | |
7 | |
8 BEGIN { | |
9 public _direct property Name => prop_get; | |
10 public _direct property Type => prop_get; | |
11 public _direct property CanBeNull => prop_get; | |
12 public _direct property DefaultValue => prop_get; | |
13 public _direct property Tag => prop_get; | |
14 } | |
15 | |
16 __PACKAGE__->PassThroughArgs; | |
17 | |
18 sub CTOR { | |
19 my $this = shift; | |
20 | |
21 $this->{$Name} or die new IMPL::InvalidArgumentException('a column name is required'); | |
22 $this->{$CanBeNull} = 0 if not exists $this->{$CanBeNull}; | |
23 UNIVERSAL::isa($this->{$Type},'IMPL::SQL::Schema::Type') or die new IMPL::InvalidArgumentException('a type is required for the column',$this->{$Name}); | |
24 } | |
25 | |
26 sub isEqualsStr { | |
27 my ($a,$b) = @_; | |
28 | |
29 if (defined $a and defined $b) { | |
30 return $a eq $b; | |
31 } else { | |
32 if (defined $a or defined $b) { | |
33 return 0; | |
34 } else { | |
35 return 1; | |
36 } | |
37 } | |
38 } | |
39 | |
40 sub isEquals { | |
41 my ($a,$b) = @_; | |
42 | |
43 if (defined $a and defined $b) { | |
44 return $a == $b; | |
45 } else { | |
46 if (defined $a or defined $b) { | |
47 return 0; | |
48 } else { | |
49 return 1; | |
50 } | |
51 } | |
52 } | |
53 | |
54 sub isSame { | |
55 my ($this,$other) = @_; | |
56 | |
57 return ($this->{$Name} eq $other->{$Name} and $this->{$CanBeNull} == $other->{$CanBeNull} and isEqualsStr($this->{$DefaultValue}, $other->{$DefaultValue}) and $this->{$Type}->isSame($other->{$Type})); | |
58 } | |
59 | |
60 1; |