| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Alzabo::Create::ColumnDefinition; |
|
2
|
|
|
|
|
|
|
|
|
3
|
9
|
|
|
9
|
|
50
|
use strict; |
|
|
9
|
|
|
|
|
23
|
|
|
|
9
|
|
|
|
|
721
|
|
|
4
|
9
|
|
|
9
|
|
50
|
use vars qw($VERSION); |
|
|
9
|
|
|
|
|
18
|
|
|
|
9
|
|
|
|
|
376
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
9
|
|
|
9
|
|
49
|
use Alzabo::Create; |
|
|
9
|
|
|
|
|
115
|
|
|
|
9
|
|
|
|
|
261
|
|
|
7
|
9
|
|
|
9
|
|
48
|
use Alzabo::Exceptions ( abbr => 'params_exception' ); |
|
|
9
|
|
|
|
|
17
|
|
|
|
9
|
|
|
|
|
186
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
9
|
|
|
9
|
|
49
|
use Params::Validate qw( :all ); |
|
|
9
|
|
|
|
|
23
|
|
|
|
9
|
|
|
|
|
2959
|
|
|
10
|
|
|
|
|
|
|
Params::Validate::validation_options |
|
11
|
|
|
|
|
|
|
( on_fail => sub { params_exception join '', @_ } ); |
|
12
|
|
|
|
|
|
|
|
|
13
|
9
|
|
|
9
|
|
57
|
use base qw(Alzabo::ColumnDefinition); |
|
|
9
|
|
|
|
|
17
|
|
|
|
9
|
|
|
|
|
9080
|
|
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
$VERSION = 2.0; |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
1; |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub new |
|
20
|
|
|
|
|
|
|
{ |
|
21
|
0
|
|
|
0
|
1
|
|
my $proto = shift; |
|
22
|
0
|
|
0
|
|
|
|
my $class = ref $proto || $proto; |
|
23
|
|
|
|
|
|
|
|
|
24
|
0
|
|
|
|
|
|
my $self = bless {}, $class; |
|
25
|
|
|
|
|
|
|
|
|
26
|
0
|
|
|
|
|
|
$self->_init(@_); |
|
27
|
|
|
|
|
|
|
|
|
28
|
0
|
|
|
|
|
|
return $self; |
|
29
|
|
|
|
|
|
|
} |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub _init |
|
32
|
|
|
|
|
|
|
{ |
|
33
|
0
|
|
|
0
|
|
|
my $self = shift; |
|
34
|
|
|
|
|
|
|
|
|
35
|
0
|
|
|
|
|
|
validate( @_, { owner => { isa => 'Alzabo::Create::Column' }, |
|
36
|
|
|
|
|
|
|
type => { type => SCALAR }, |
|
37
|
|
|
|
|
|
|
length => { type => UNDEF | SCALAR, |
|
38
|
|
|
|
|
|
|
optional => 1 }, |
|
39
|
|
|
|
|
|
|
precision => { type => UNDEF | SCALAR, |
|
40
|
|
|
|
|
|
|
optional => 1 }, |
|
41
|
|
|
|
|
|
|
} ); |
|
42
|
0
|
|
|
|
|
|
my %p = @_; |
|
43
|
|
|
|
|
|
|
|
|
44
|
0
|
|
|
|
|
|
$p{type} = |
|
45
|
|
|
|
|
|
|
$p{owner}->table->schema->rules->validate_column_type( $p{type}, $p{owner}->table ); |
|
46
|
0
|
|
|
|
|
|
foreach ( qw( owner type ) ) |
|
47
|
|
|
|
|
|
|
{ |
|
48
|
0
|
0
|
|
|
|
|
$self->{$_} = $p{$_} if exists $p{$_}; |
|
49
|
|
|
|
|
|
|
} |
|
50
|
|
|
|
|
|
|
} |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub alter |
|
53
|
|
|
|
|
|
|
{ |
|
54
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
55
|
|
|
|
|
|
|
|
|
56
|
0
|
|
|
|
|
|
validate( @_, { type => { type => SCALAR }, |
|
57
|
|
|
|
|
|
|
length => { type => UNDEF | SCALAR, |
|
58
|
|
|
|
|
|
|
optional => 1 }, |
|
59
|
|
|
|
|
|
|
precision => { type => UNDEF | SCALAR, |
|
60
|
|
|
|
|
|
|
optional => 1 }, |
|
61
|
|
|
|
|
|
|
} ); |
|
62
|
0
|
|
|
|
|
|
my %p = @_; |
|
63
|
|
|
|
|
|
|
|
|
64
|
0
|
|
|
|
|
|
my $old_type = $self->{type}; |
|
65
|
0
|
|
|
|
|
|
my $old_length = $self->{length}; |
|
66
|
0
|
|
|
|
|
|
my $old_precision = $self->{precision}; |
|
67
|
|
|
|
|
|
|
|
|
68
|
0
|
0
|
|
|
|
|
$self->{length} = $p{length} if exists $p{length}; |
|
69
|
0
|
0
|
|
|
|
|
$self->{precision} = $p{precision} if exists $p{precision}; |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
eval |
|
72
|
0
|
|
|
|
|
|
{ |
|
73
|
0
|
|
|
|
|
|
$self->{type} = |
|
74
|
|
|
|
|
|
|
$self->owner->table->schema->rules->validate_column_type($p{type}, $self->owner->table); |
|
75
|
0
|
0
|
|
|
|
|
$self->owner->table->schema->rules->validate_primary_key($self->owner) |
|
76
|
|
|
|
|
|
|
if $self->owner->is_primary_key; |
|
77
|
0
|
|
|
|
|
|
$self->owner->table->schema->rules->validate_column_length($self->owner); |
|
78
|
|
|
|
|
|
|
}; |
|
79
|
0
|
0
|
|
|
|
|
if ($@) |
|
80
|
|
|
|
|
|
|
{ |
|
81
|
0
|
|
|
|
|
|
$self->{type} = $old_type; |
|
82
|
0
|
|
|
|
|
|
$self->{length} = $old_length; |
|
83
|
0
|
|
|
|
|
|
$self->{precision} = $old_precision; |
|
84
|
|
|
|
|
|
|
|
|
85
|
0
|
|
|
|
|
|
rethrow_exception($@); |
|
86
|
|
|
|
|
|
|
} |
|
87
|
|
|
|
|
|
|
} |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
sub set_type |
|
90
|
|
|
|
|
|
|
{ |
|
91
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
92
|
|
|
|
|
|
|
|
|
93
|
0
|
|
|
|
|
|
validate_pos( @_, { type => SCALAR } ); |
|
94
|
0
|
|
|
|
|
|
my $type = shift; |
|
95
|
|
|
|
|
|
|
|
|
96
|
0
|
|
|
|
|
|
my $old_type = $self->{type}; |
|
97
|
|
|
|
|
|
|
eval |
|
98
|
0
|
|
|
|
|
|
{ |
|
99
|
0
|
|
|
|
|
|
$self->{type} = |
|
100
|
|
|
|
|
|
|
$self->owner->table->schema->rules->validate_column_type($type, $self->owner->table); |
|
101
|
|
|
|
|
|
|
$self->owner->table->schema->rules->validate_primary_key($self->owner) |
|
102
|
0
|
0
|
|
|
|
|
if eval { $self->owner->is_primary_key }; |
|
|
0
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
# eval ^^ cause if we're creating the column its not in the table yet |
|
104
|
|
|
|
|
|
|
}; |
|
105
|
0
|
0
|
|
|
|
|
if ($@) |
|
106
|
|
|
|
|
|
|
{ |
|
107
|
0
|
|
|
|
|
|
$self->{type} = $old_type; |
|
108
|
|
|
|
|
|
|
|
|
109
|
0
|
|
|
|
|
|
rethrow_exception($@); |
|
110
|
|
|
|
|
|
|
} |
|
111
|
|
|
|
|
|
|
} |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
sub set_length |
|
114
|
|
|
|
|
|
|
{ |
|
115
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
116
|
|
|
|
|
|
|
|
|
117
|
0
|
|
|
|
|
|
validate( @_, { length => { type => UNDEF | SCALAR }, |
|
118
|
|
|
|
|
|
|
precision => { type => UNDEF | SCALAR, |
|
119
|
|
|
|
|
|
|
optional => 1 } } ); |
|
120
|
0
|
|
|
|
|
|
my %p = @_; |
|
121
|
|
|
|
|
|
|
|
|
122
|
0
|
|
|
|
|
|
my $old_length = $self->{length}; |
|
123
|
0
|
|
|
|
|
|
my $old_precision = $self->{precision}; |
|
124
|
0
|
|
|
|
|
|
$self->{length} = $p{length}; |
|
125
|
0
|
0
|
|
|
|
|
$self->{precision} = $p{precision} if exists $p{precision}; |
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
eval |
|
128
|
0
|
|
|
|
|
|
{ |
|
129
|
0
|
|
|
|
|
|
$self->owner->table->schema->rules->validate_column_length($self->owner); |
|
130
|
|
|
|
|
|
|
}; |
|
131
|
0
|
0
|
|
|
|
|
if ($@) |
|
132
|
|
|
|
|
|
|
{ |
|
133
|
0
|
|
|
|
|
|
$self->{length} = $old_length; |
|
134
|
0
|
|
|
|
|
|
$self->{precision} = $old_precision; |
|
135
|
|
|
|
|
|
|
|
|
136
|
0
|
|
|
|
|
|
rethrow_exception($@); |
|
137
|
|
|
|
|
|
|
} |
|
138
|
|
|
|
|
|
|
} |
|
139
|
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
1; |
|
141
|
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
__END__ |