annotate Lib/IMPL/SQL/Schema/Column.pm @ 208:3d433a977e3b

corrected RestController for empty PAT_INFO corrected charset for ErrorHandler
author sergey
date Fri, 18 May 2012 18:43:00 +0400
parents 4d0e1962161c
children 5c82eec23bb6
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
168
6148f89bb7bf IMPL::SQL::Schema::Traits::Diff alfa version
sourcer
parents: 167
diff changeset
5 use IMPL::lang qw( :DEFAULT :compare :declare :constants :hash );
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
194
4d0e1962161c Replaced tabs with spaces
cin
parents: 168
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
194
4d0e1962161c Replaced tabs with spaces
cin
parents: 168
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 (
194
4d0e1962161c Replaced tabs with spaces
cin
parents: 168
diff changeset
35 $this->{$name} eq $other->{$name}
4d0e1962161c Replaced tabs with spaces
cin
parents: 168
diff changeset
36 and $this->{$isNullable} == $other->{$isNullable}
4d0e1962161c Replaced tabs with spaces
cin
parents: 168
diff changeset
37 and equals_s($this->{$defaultValue}, $other->{$defaultValue})
4d0e1962161c Replaced tabs with spaces
cin
parents: 168
diff changeset
38 and $this->{$type}->SameValue($other->{$type})
167
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
168
6148f89bb7bf IMPL::SQL::Schema::Traits::Diff alfa version
sourcer
parents: 167
diff changeset
42 sub SetType {
194
4d0e1962161c Replaced tabs with spaces
cin
parents: 168
diff changeset
43 my ($this,$newType) = @_;
4d0e1962161c Replaced tabs with spaces
cin
parents: 168
diff changeset
44
4d0e1962161c Replaced tabs with spaces
cin
parents: 168
diff changeset
45 $this->{$type} = $newType;
168
6148f89bb7bf IMPL::SQL::Schema::Traits::Diff alfa version
sourcer
parents: 167
diff changeset
46 }
6148f89bb7bf IMPL::SQL::Schema::Traits::Diff alfa version
sourcer
parents: 167
diff changeset
47
6148f89bb7bf IMPL::SQL::Schema::Traits::Diff alfa version
sourcer
parents: 167
diff changeset
48 sub SetDefaultValue {
194
4d0e1962161c Replaced tabs with spaces
cin
parents: 168
diff changeset
49 my ($this,$value) = @_;
4d0e1962161c Replaced tabs with spaces
cin
parents: 168
diff changeset
50
4d0e1962161c Replaced tabs with spaces
cin
parents: 168
diff changeset
51 $this->{$defaultValue} = $value;
168
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
6148f89bb7bf IMPL::SQL::Schema::Traits::Diff alfa version
sourcer
parents: 167
diff changeset
54 sub SetNullable {
194
4d0e1962161c Replaced tabs with spaces
cin
parents: 168
diff changeset
55 my ($this, $value) = @_;
4d0e1962161c Replaced tabs with spaces
cin
parents: 168
diff changeset
56
4d0e1962161c Replaced tabs with spaces
cin
parents: 168
diff changeset
57 $this->{$isNullable} = $value;
168
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
6148f89bb7bf IMPL::SQL::Schema::Traits::Diff alfa version
sourcer
parents: 167
diff changeset
60 sub SetOptions {
194
4d0e1962161c Replaced tabs with spaces
cin
parents: 168
diff changeset
61 my ($this,$diff) = @_;
4d0e1962161c Replaced tabs with spaces
cin
parents: 168
diff changeset
62
4d0e1962161c Replaced tabs with spaces
cin
parents: 168
diff changeset
63 return unless ref $diff eq 'HASH';
4d0e1962161c Replaced tabs with spaces
cin
parents: 168
diff changeset
64
4d0e1962161c Replaced tabs with spaces
cin
parents: 168
diff changeset
65 $this->tag({}) unless $this->tag;
4d0e1962161c Replaced tabs with spaces
cin
parents: 168
diff changeset
66
4d0e1962161c Replaced tabs with spaces
cin
parents: 168
diff changeset
67 hashApply($this->tag,$diff);
168
6148f89bb7bf IMPL::SQL::Schema::Traits::Diff alfa version
sourcer
parents: 167
diff changeset
68 }
6148f89bb7bf IMPL::SQL::Schema::Traits::Diff alfa version
sourcer
parents: 167
diff changeset
69
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
70 1;