annotate Lib/IMPL/SQL/Schema/Column.pm @ 167:1f7a6d762394

SQL schema in progress
author sourcer
date Thu, 12 May 2011 08:57:19 +0400
parents 76515373dac0
children 6148f89bb7bf
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
167
1f7a6d762394 SQL schema in progress
sourcer
parents: 165
diff changeset
5 use IMPL::lang qw( :DEFAULT :compare :declare :constants );
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
6 use IMPL::Class::Property::Direct;
167
1f7a6d762394 SQL schema in progress
sourcer
parents: 165
diff changeset
7 use IMPL::Exception();
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
8
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
9 BEGIN {
167
1f7a6d762394 SQL schema in progress
sourcer
parents: 165
diff changeset
10 public _direct property name => PROP_GET;
1f7a6d762394 SQL schema in progress
sourcer
parents: 165
diff changeset
11 public _direct property type => PROP_GET;
1f7a6d762394 SQL schema in progress
sourcer
parents: 165
diff changeset
12 public _direct property isNullable => PROP_GET;
1f7a6d762394 SQL schema in progress
sourcer
parents: 165
diff changeset
13 public _direct property defaultValue => PROP_GET;
1f7a6d762394 SQL schema in progress
sourcer
parents: 165
diff changeset
14 public _direct property tag => PROP_GET;
49
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
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
17 __PACKAGE__->PassThroughArgs;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
18
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
19 sub CTOR {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
20 my $this = shift;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
21
167
1f7a6d762394 SQL schema in progress
sourcer
parents: 165
diff changeset
22 $this->{$name} or
1f7a6d762394 SQL schema in progress
sourcer
parents: 165
diff changeset
23 die new IMPL::InvalidArgumentException('A column name is required');
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
24
167
1f7a6d762394 SQL schema in progress
sourcer
parents: 165
diff changeset
25 $this->{$isNullable} = 0 if not exists $this->{$isNullable};
1f7a6d762394 SQL schema in progress
sourcer
parents: 165
diff changeset
26
1f7a6d762394 SQL schema in progress
sourcer
parents: 165
diff changeset
27 is( $this->{$type}, typeof IMPL::SQL::Schema::Type) or
1f7a6d762394 SQL schema in progress
sourcer
parents: 165
diff changeset
28 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
29 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
30
167
1f7a6d762394 SQL schema in progress
sourcer
parents: 165
diff changeset
31 sub SameValue {
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
32 my ($this,$other) = @_;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
33
167
1f7a6d762394 SQL schema in progress
sourcer
parents: 165
diff changeset
34 return (
1f7a6d762394 SQL schema in progress
sourcer
parents: 165
diff changeset
35 $this->{$name} eq $other->{$name}
1f7a6d762394 SQL schema in progress
sourcer
parents: 165
diff changeset
36 and $this->{$isNullable} == $other->{$isNullable}
1f7a6d762394 SQL schema in progress
sourcer
parents: 165
diff changeset
37 and equals_s($this->{$defaultValue}, $other->{$defaultValue})
1f7a6d762394 SQL schema in progress
sourcer
parents: 165
diff changeset
38 and $this->{$type}->SameValue($other->{$type})
1f7a6d762394 SQL schema in progress
sourcer
parents: 165
diff changeset
39 );
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
40 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
41
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
42 1;