annotate Lib/IMPL/SQL/Schema/Column.pm @ 166:4267a2ac3d46

Added Class::Template, Rewritten SQL::Schema 'use parent' directive instead of 'use base'
author wizard
date Sat, 23 Apr 2011 23:12:06 +0400
parents 76515373dac0
children 1f7a6d762394
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 use strict;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
2 package IMPL::SQL::Schema::Column;
165
76515373dac0 Added Class::Template,
wizard
parents: 163
diff changeset
3 use parent qw(IMPL::Object IMPL::Object::Autofill);
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
4
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
5 use IMPL::Class::Property;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
6 use IMPL::Class::Property::Direct;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
7
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
8 BEGIN {
165
76515373dac0 Added Class::Template,
wizard
parents: 163
diff changeset
9 public _direct property name => prop_get;
76515373dac0 Added Class::Template,
wizard
parents: 163
diff changeset
10 public _direct property type => prop_get;
76515373dac0 Added Class::Template,
wizard
parents: 163
diff changeset
11 public _direct property isNullable => prop_get;
76515373dac0 Added Class::Template,
wizard
parents: 163
diff changeset
12 public _direct property defaultValue => prop_get;
76515373dac0 Added Class::Template,
wizard
parents: 163
diff changeset
13 public _direct property tag => prop_get;
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
14 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
15
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
16 __PACKAGE__->PassThroughArgs;
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 sub CTOR {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
19 my $this = shift;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
20
165
76515373dac0 Added Class::Template,
wizard
parents: 163
diff changeset
21 $this->{$name} or die new IMPL::InvalidArgumentException('a column name is required');
76515373dac0 Added Class::Template,
wizard
parents: 163
diff changeset
22 $this->{$isNullable} = 0 if not exists $this->{$isNullable};
76515373dac0 Added Class::Template,
wizard
parents: 163
diff changeset
23 UNIVERSAL::isa($this->{$type},'IMPL::SQL::Schema::Type') or die new IMPL::InvalidArgumentException('a type is required for the column',$this->{$name});
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
24 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
25
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
26 sub isEqualsStr {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
27 my ($a,$b) = @_;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
28
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
29 if (defined $a and defined $b) {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
30 return $a eq $b;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
31 } else {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
32 if (defined $a or defined $b) {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
33 return 0;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
34 } else {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
35 return 1;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
36 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
37 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
38 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
39
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
40 sub isEquals {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
41 my ($a,$b) = @_;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
42
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
43 if (defined $a and defined $b) {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
44 return $a == $b;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
45 } else {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
46 if (defined $a or defined $b) {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
47 return 0;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
48 } else {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
49 return 1;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
50 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
51 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
52 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
53
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
54 sub isSame {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
55 my ($this,$other) = @_;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
56
165
76515373dac0 Added Class::Template,
wizard
parents: 163
diff changeset
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
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
58 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
59
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
60 1;