annotate Lib/IMPL/SQL/Schema/Column.pm @ 289:85572f512abc

*TTView refactoring
author cin
date Wed, 20 Feb 2013 02:25:30 +0400
parents 68d905f8dc43
children 77df11605d3a
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;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
3
278
4ddb27ff4a0b core refactoring
cin
parents: 232
diff changeset
4 use IMPL::lang qw( :DEFAULT :compare :hash );
167
1f7a6d762394 SQL schema in progress
sourcer
parents: 165
diff changeset
5 use IMPL::Exception();
278
4ddb27ff4a0b core refactoring
cin
parents: 232
diff changeset
6 use IMPL::Const qw(:prop);
4ddb27ff4a0b core refactoring
cin
parents: 232
diff changeset
7 use IMPL::declare {
4ddb27ff4a0b core refactoring
cin
parents: 232
diff changeset
8 base => [
4ddb27ff4a0b core refactoring
cin
parents: 232
diff changeset
9 'IMPL::Object' => undef,
4ddb27ff4a0b core refactoring
cin
parents: 232
diff changeset
10 'IMPL::Object::Autofill' => '@_'
4ddb27ff4a0b core refactoring
cin
parents: 232
diff changeset
11 ],
4ddb27ff4a0b core refactoring
cin
parents: 232
diff changeset
12 props => [
4ddb27ff4a0b core refactoring
cin
parents: 232
diff changeset
13 name => PROP_RO | PROP_DIRECT,
4ddb27ff4a0b core refactoring
cin
parents: 232
diff changeset
14 type => PROP_RO | PROP_DIRECT,
4ddb27ff4a0b core refactoring
cin
parents: 232
diff changeset
15 isNullable => PROP_RO | PROP_DIRECT,
4ddb27ff4a0b core refactoring
cin
parents: 232
diff changeset
16 defaultValue => PROP_RO | PROP_DIRECT,
4ddb27ff4a0b core refactoring
cin
parents: 232
diff changeset
17 tag => PROP_RO | PROP_DIRECT
4ddb27ff4a0b core refactoring
cin
parents: 232
diff changeset
18 ]
4ddb27ff4a0b core refactoring
cin
parents: 232
diff changeset
19 };
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
20
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
21 sub CTOR {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
22 my $this = shift;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
23
167
1f7a6d762394 SQL schema in progress
sourcer
parents: 165
diff changeset
24 $this->{$name} or
194
4d0e1962161c Replaced tabs with spaces
cin
parents: 168
diff changeset
25 die new IMPL::InvalidArgumentException('A column name is required');
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
26
282
68d905f8dc43 *IMPL::SQL fixed warnings
cin
parents: 278
diff changeset
27 $this->{$isNullable} ||= 0; # if not exists $this->{$isNullable};
167
1f7a6d762394 SQL schema in progress
sourcer
parents: 165
diff changeset
28
1f7a6d762394 SQL schema in progress
sourcer
parents: 165
diff changeset
29 is( $this->{$type}, typeof IMPL::SQL::Schema::Type) or
194
4d0e1962161c Replaced tabs with spaces
cin
parents: 168
diff changeset
30 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
31 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
32
167
1f7a6d762394 SQL schema in progress
sourcer
parents: 165
diff changeset
33 sub SameValue {
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
34 my ($this,$other) = @_;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
35
167
1f7a6d762394 SQL schema in progress
sourcer
parents: 165
diff changeset
36 return (
194
4d0e1962161c Replaced tabs with spaces
cin
parents: 168
diff changeset
37 $this->{$name} eq $other->{$name}
4d0e1962161c Replaced tabs with spaces
cin
parents: 168
diff changeset
38 and $this->{$isNullable} == $other->{$isNullable}
4d0e1962161c Replaced tabs with spaces
cin
parents: 168
diff changeset
39 and equals_s($this->{$defaultValue}, $other->{$defaultValue})
4d0e1962161c Replaced tabs with spaces
cin
parents: 168
diff changeset
40 and $this->{$type}->SameValue($other->{$type})
167
1f7a6d762394 SQL schema in progress
sourcer
parents: 165
diff changeset
41 );
49
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
168
6148f89bb7bf IMPL::SQL::Schema::Traits::Diff alfa version
sourcer
parents: 167
diff changeset
44 sub SetType {
194
4d0e1962161c Replaced tabs with spaces
cin
parents: 168
diff changeset
45 my ($this,$newType) = @_;
4d0e1962161c Replaced tabs with spaces
cin
parents: 168
diff changeset
46
4d0e1962161c Replaced tabs with spaces
cin
parents: 168
diff changeset
47 $this->{$type} = $newType;
168
6148f89bb7bf IMPL::SQL::Schema::Traits::Diff alfa version
sourcer
parents: 167
diff changeset
48 }
6148f89bb7bf IMPL::SQL::Schema::Traits::Diff alfa version
sourcer
parents: 167
diff changeset
49
6148f89bb7bf IMPL::SQL::Schema::Traits::Diff alfa version
sourcer
parents: 167
diff changeset
50 sub SetDefaultValue {
194
4d0e1962161c Replaced tabs with spaces
cin
parents: 168
diff changeset
51 my ($this,$value) = @_;
4d0e1962161c Replaced tabs with spaces
cin
parents: 168
diff changeset
52
4d0e1962161c Replaced tabs with spaces
cin
parents: 168
diff changeset
53 $this->{$defaultValue} = $value;
168
6148f89bb7bf IMPL::SQL::Schema::Traits::Diff alfa version
sourcer
parents: 167
diff changeset
54 }
6148f89bb7bf IMPL::SQL::Schema::Traits::Diff alfa version
sourcer
parents: 167
diff changeset
55
6148f89bb7bf IMPL::SQL::Schema::Traits::Diff alfa version
sourcer
parents: 167
diff changeset
56 sub SetNullable {
194
4d0e1962161c Replaced tabs with spaces
cin
parents: 168
diff changeset
57 my ($this, $value) = @_;
4d0e1962161c Replaced tabs with spaces
cin
parents: 168
diff changeset
58
4d0e1962161c Replaced tabs with spaces
cin
parents: 168
diff changeset
59 $this->{$isNullable} = $value;
168
6148f89bb7bf IMPL::SQL::Schema::Traits::Diff alfa version
sourcer
parents: 167
diff changeset
60 }
6148f89bb7bf IMPL::SQL::Schema::Traits::Diff alfa version
sourcer
parents: 167
diff changeset
61
6148f89bb7bf IMPL::SQL::Schema::Traits::Diff alfa version
sourcer
parents: 167
diff changeset
62 sub SetOptions {
194
4d0e1962161c Replaced tabs with spaces
cin
parents: 168
diff changeset
63 my ($this,$diff) = @_;
4d0e1962161c Replaced tabs with spaces
cin
parents: 168
diff changeset
64
4d0e1962161c Replaced tabs with spaces
cin
parents: 168
diff changeset
65 return unless ref $diff eq 'HASH';
4d0e1962161c Replaced tabs with spaces
cin
parents: 168
diff changeset
66
4d0e1962161c Replaced tabs with spaces
cin
parents: 168
diff changeset
67 $this->tag({}) unless $this->tag;
4d0e1962161c Replaced tabs with spaces
cin
parents: 168
diff changeset
68
4d0e1962161c Replaced tabs with spaces
cin
parents: 168
diff changeset
69 hashApply($this->tag,$diff);
168
6148f89bb7bf IMPL::SQL::Schema::Traits::Diff alfa version
sourcer
parents: 167
diff changeset
70 }
6148f89bb7bf IMPL::SQL::Schema::Traits::Diff alfa version
sourcer
parents: 167
diff changeset
71
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
72 1;