annotate Lib/IMPL/SQL/Schema/Column.pm @ 347:3eafa6fefa9f

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