line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package DBIx::Model::Column; |
2
|
1
|
|
|
1
|
|
12
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
30
|
|
3
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
30
|
|
4
|
1
|
|
|
1
|
|
5
|
use Types::Standard qw/ArrayRef Bool Int Str Undef/; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
8
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '0.0.1_2'; |
7
|
|
|
|
|
|
|
our $INLINE = { |
8
|
|
|
|
|
|
|
chain => { |
9
|
|
|
|
|
|
|
is => 'rw', |
10
|
|
|
|
|
|
|
isa => Int, |
11
|
|
|
|
|
|
|
}, |
12
|
|
|
|
|
|
|
table => { |
13
|
|
|
|
|
|
|
is => 'ro', |
14
|
|
|
|
|
|
|
required => 1, |
15
|
|
|
|
|
|
|
weaken => 1, |
16
|
|
|
|
|
|
|
}, |
17
|
|
|
|
|
|
|
name => { |
18
|
|
|
|
|
|
|
is => 'ro', |
19
|
|
|
|
|
|
|
isa => Str, |
20
|
|
|
|
|
|
|
required => 1, |
21
|
|
|
|
|
|
|
}, |
22
|
|
|
|
|
|
|
name_lc => { |
23
|
|
|
|
|
|
|
is => 'ro', |
24
|
|
|
|
|
|
|
init_arg => undef, |
25
|
|
|
|
|
|
|
default => sub { lc $_[0]->name }, |
26
|
|
|
|
|
|
|
}, |
27
|
|
|
|
|
|
|
full_name => { |
28
|
|
|
|
|
|
|
is => 'ro', |
29
|
|
|
|
|
|
|
init_arg => undef, |
30
|
|
|
|
|
|
|
default => sub { $_[0]->table->name . '.' . $_[0]->name }, |
31
|
|
|
|
|
|
|
}, |
32
|
|
|
|
|
|
|
full_name_lc => { |
33
|
|
|
|
|
|
|
is => 'ro', |
34
|
|
|
|
|
|
|
init_arg => undef, |
35
|
|
|
|
|
|
|
default => sub { lc $_[0]->full_name }, |
36
|
|
|
|
|
|
|
}, |
37
|
|
|
|
|
|
|
primary => { |
38
|
|
|
|
|
|
|
is => 'ro', |
39
|
|
|
|
|
|
|
isa => Bool, |
40
|
|
|
|
|
|
|
default => sub { 0 }, |
41
|
|
|
|
|
|
|
}, |
42
|
|
|
|
|
|
|
ref_count => { |
43
|
|
|
|
|
|
|
is => 'rw', |
44
|
|
|
|
|
|
|
isa => Int, |
45
|
|
|
|
|
|
|
default => 0, |
46
|
|
|
|
|
|
|
}, |
47
|
|
|
|
|
|
|
size => { |
48
|
|
|
|
|
|
|
is => 'ro', |
49
|
|
|
|
|
|
|
isa => Int | Undef, |
50
|
|
|
|
|
|
|
}, |
51
|
|
|
|
|
|
|
target_count => { |
52
|
|
|
|
|
|
|
is => 'rw', |
53
|
|
|
|
|
|
|
isa => Int, |
54
|
|
|
|
|
|
|
default => 0, |
55
|
|
|
|
|
|
|
}, |
56
|
|
|
|
|
|
|
type => { |
57
|
|
|
|
|
|
|
is => 'ro', |
58
|
|
|
|
|
|
|
isa => Str, |
59
|
|
|
|
|
|
|
required => 1, |
60
|
|
|
|
|
|
|
}, |
61
|
|
|
|
|
|
|
nullable => { |
62
|
|
|
|
|
|
|
is => 'ro', |
63
|
|
|
|
|
|
|
isa => Bool, |
64
|
|
|
|
|
|
|
required => 1, |
65
|
|
|
|
|
|
|
}, |
66
|
|
|
|
|
|
|
}; |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
sub as_string { |
69
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
70
|
0
|
|
|
|
|
|
my $prefix = shift; |
71
|
0
|
|
|
|
|
|
my $str = $prefix . $self->name . ' ' . $self->type; |
72
|
0
|
0
|
|
|
|
|
$str .= '(' . $self->size . ')' if $self->size; |
73
|
0
|
0
|
|
|
|
|
$str .= ' NOT NULL' unless $self->nullable; |
74
|
0
|
|
|
|
|
|
return $str; |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
sub bump_ref_count { |
78
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
79
|
0
|
|
|
|
|
|
$self->ref_count( $self->ref_count + 1 ); |
80
|
0
|
|
|
|
|
|
$self->table->bump_ref_count; |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
sub bump_target_count { |
84
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
85
|
0
|
|
|
|
|
|
$self->target_count( $self->target_count + 1 ); |
86
|
0
|
|
|
|
|
|
$self->table->bump_target_count; |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
### DO NOT EDIT BELOW! (generated by Class::Inline v0.0.1) |
90
|
|
|
|
|
|
|
#<<< |
91
|
0
|
|
|
0
|
0
|
|
require Carp;require Scalar::Util;our@ATTRS_UNEX=(undef);sub new {my$class= |
92
|
0
|
0
|
|
|
|
|
shift;my$self={@_ ? @_ > 1 ? @_ : %{$_[0]}: ()};map {local$Carp::CarpLevel= |
|
0
|
0
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
$Carp::CarpLevel + 1;Carp::croak( |
94
|
|
|
|
|
|
|
"missing attribute DBIx::Model::Column::$_ is required")unless exists$self-> |
95
|
0
|
0
|
|
|
|
|
{$_}}'name','nullable','table','type';map {delete$self->{$_}}'full_name', |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
96
|
0
|
0
|
|
|
|
|
'full_name_lc','name_lc';if (@ATTRS_UNEX){map {local$Carp::CarpLevel= |
|
0
|
|
|
|
|
|
|
97
|
0
|
|
|
|
|
|
$Carp::CarpLevel + 1;Carp::carp( |
98
|
0
|
|
|
|
|
|
"DBIx::Model::Column attribute '$_' unexpected");delete$self->{$_ }}sort |
99
|
0
|
|
|
|
|
|
grep {not exists$INLINE->{$_ }}keys %$self}else {@ATTRS_UNEX=map {delete |
|
0
|
|
|
|
|
|
|
100
|
0
|
|
0
|
|
|
|
$self->{$_ };$_}grep {not exists$INLINE->{$_ }}keys %$self}bless$self,ref |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
101
|
0
|
|
|
|
|
|
$class || $class;map {$self->{$_ }=eval {$INLINE->{$_ }->{'isa'}->($self->{ |
102
|
0
|
0
|
|
|
|
|
$_ })};Carp::croak(qq{DBIx::Model::Column::$_ value invalid ($@)})if $@}grep |
|
0
|
|
|
|
|
|
|
103
|
0
|
|
|
|
|
|
{exists$self->{$_ }}'chain','name','nullable','primary','ref_count','size', |
|
0
|
|
|
|
|
|
|
104
|
0
|
|
|
|
|
|
'target_count','type';map {Scalar::Util::weaken($self->{$_ })}grep {defined |
|
0
|
|
|
|
|
|
|
105
|
0
|
|
0
|
0
|
|
|
$self->{$_ }// undef}'table';$self}sub __ro {my (undef,undef,undef,$sub)= |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
106
|
0
|
|
0
|
|
|
|
caller(1);local$Carp::CarpLevel=$Carp::CarpLevel + 1;Carp::croak( |
|
0
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
"attribute $sub is read-only (value: '" .($_[1]// 'undef')."')")}sub chain { |
108
|
0
|
0
|
|
0
|
0
|
|
if (@_ > 1){$_[0]{'chain'}=eval {$INLINE->{'chain'}->{'isa'}->($_[1])}; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
109
|
0
|
0
|
|
|
|
|
Carp::croak('invalid (DBIx::Model::Column::chain) value: '.$@)if $@;return |
110
|
0
|
0
|
0
|
0
|
0
|
|
$_[0]}$_[0]{'chain'}// undef}sub full_name {$_[0]->__ro($_[1])if @_ > 1;$_[0 |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
111
|
0
|
|
0
|
|
|
|
]{'full_name'}//= $INLINE->{'full_name'}->{'default'}->($_[0])}sub |
112
|
0
|
0
|
|
0
|
0
|
|
full_name_lc {$_[0]->__ro($_[1])if @_ > 1;$_[0]{'full_name_lc'}//= $INLINE-> |
113
|
0
|
0
|
0
|
0
|
0
|
|
{'full_name_lc'}->{'default'}->($_[0])}sub name {$_[0]->__ro($_[1])if @_ > 1 |
|
0
|
|
|
|
|
|
|
114
|
0
|
0
|
|
0
|
0
|
|
;$_[0]{'name'}}sub name_lc {$_[0]->__ro($_[1])if @_ > 1;$_[0]{'name_lc'}//= |
|
0
|
|
|
|
|
|
|
115
|
0
|
0
|
0
|
0
|
0
|
|
$INLINE->{'name_lc'}->{'default'}->($_[0])}sub nullable {$_[0]->__ro($_[1]) |
|
0
|
|
|
|
|
|
|
116
|
0
|
0
|
|
0
|
0
|
|
if @_ > 1;$_[0]{'nullable'}}sub primary {$_[0]->__ro($_[1])if @_ > 1;$_[0]{ |
|
0
|
|
|
|
|
|
|
117
|
0
|
|
0
|
|
|
|
'primary'}//= eval {$INLINE->{'primary'}->{'isa'}->($INLINE->{'primary'}->{ |
118
|
0
|
0
|
|
|
|
|
'default'}->($_[0]))};Carp::croak( |
|
0
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
'invalid (DBIx::Model::Column::primary) default value: ' .$@)if $@;$_[0]{ |
120
|
0
|
0
|
|
0
|
0
|
|
'primary'}}sub ref_count {if (@_ > 1){$_[0]{'ref_count'}=eval {$INLINE->{ |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
121
|
0
|
0
|
|
|
|
|
'ref_count'}->{'isa'}->($_[1])};Carp::croak( |
|
0
|
|
|
|
|
|
|
122
|
0
|
|
|
|
|
|
'invalid (DBIx::Model::Column::ref_count) value: '.$@)if $@;return $_[0]}$_[ |
123
|
0
|
|
0
|
|
|
|
0]{'ref_count'}//= eval {$INLINE->{'ref_count'}->{'isa'}->($INLINE->{ |
124
|
0
|
0
|
|
|
|
|
'ref_count'}->{'default'})};Carp::croak( |
|
0
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
'invalid (DBIx::Model::Column::ref_count) default value: ' .$@)if $@;$_[0]{ |
126
|
0
|
0
|
0
|
0
|
0
|
|
'ref_count'}}sub size {$_[0]->__ro($_[1])if @_ > 1;$_[0]{'size'}// undef}sub |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
127
|
0
|
0
|
|
0
|
0
|
|
table {$_[0]->__ro($_[1])if @_ > 1;$_[0]{'table'}}sub target_count {if (@_ > |
|
0
|
0
|
|
0
|
0
|
|
|
|
0
|
|
|
|
|
|
|
128
|
0
|
|
|
|
|
|
1){$_[0]{'target_count'}=eval {$INLINE->{'target_count'}->{'isa'}->($_[1])}; |
|
0
|
|
|
|
|
|
|
129
|
0
|
0
|
|
|
|
|
Carp::croak('invalid (DBIx::Model::Column::target_count) value: '.$@)if $@; |
130
|
0
|
|
0
|
|
|
|
return $_[0]}$_[0]{'target_count'}//= eval {$INLINE->{'target_count'}->{ |
|
0
|
|
|
|
|
|
|
131
|
0
|
0
|
|
|
|
|
'isa'}->($INLINE->{'target_count'}->{'default'})};Carp::croak( |
|
0
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
'invalid (DBIx::Model::Column::target_count) default value: ' .$@)if $@;$_[0 |
133
|
0
|
0
|
|
0
|
0
|
|
]{'target_count'}}sub type {$_[0]->__ro($_[1])if @_ > 1;$_[0]{'type'}} |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
#>>> |
135
|
|
|
|
|
|
|
### DO NOT EDIT ABOVE! (generated by Class::Inline v0.0.1) |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
1; |