49
|
1 use strict;
|
|
2 package IMPL::SQL::Schema::Column;
|
165
|
3 use parent qw(IMPL::Object IMPL::Object::Autofill);
|
49
|
4
|
|
5 use IMPL::Class::Property;
|
|
6 use IMPL::Class::Property::Direct;
|
|
7
|
|
8 BEGIN {
|
165
|
9 public _direct property name => prop_get;
|
|
10 public _direct property type => prop_get;
|
|
11 public _direct property isNullable => prop_get;
|
|
12 public _direct property defaultValue => prop_get;
|
|
13 public _direct property tag => prop_get;
|
49
|
14 }
|
|
15
|
|
16 __PACKAGE__->PassThroughArgs;
|
|
17
|
|
18 sub CTOR {
|
|
19 my $this = shift;
|
|
20
|
165
|
21 $this->{$name} or die new IMPL::InvalidArgumentException('a column name is required');
|
|
22 $this->{$isNullable} = 0 if not exists $this->{$isNullable};
|
|
23 UNIVERSAL::isa($this->{$type},'IMPL::SQL::Schema::Type') or die new IMPL::InvalidArgumentException('a type is required for the column',$this->{$name});
|
49
|
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
|
165
|
57 return ($this->{$name} eq $other->{$name} and $this->{$isNullable} == $other->{$isNullable} and isEqualsStr($this->{$defaultValue}, $other->{$defaultValue}) and $this->{$type}->isSame($other->{$type}));
|
49
|
58 }
|
|
59
|
|
60 1;
|