line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Class::DBI::FormBuilder::Meta::Column; |
2
|
31
|
|
|
31
|
|
170
|
use strict; |
|
31
|
|
|
|
|
58
|
|
|
31
|
|
|
|
|
1170
|
|
3
|
31
|
|
|
31
|
|
166
|
use warnings; |
|
31
|
|
|
|
|
56
|
|
|
31
|
|
|
|
|
2187
|
|
4
|
|
|
|
|
|
|
|
5
|
31
|
|
|
31
|
|
168
|
use base qw( Class::Accessor Class::Data::Inheritable ); |
|
31
|
|
|
|
|
54
|
|
|
31
|
|
|
|
|
8107
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
BEGIN |
8
|
|
|
|
|
|
|
{ |
9
|
|
|
|
|
|
|
# this is the list of column meta that we are interested in - add more items if wanted |
10
|
31
|
|
|
31
|
|
3537
|
__PACKAGE__->mk_classdata( 'column_attributes', [ qw( column_def column_size decimal_digits |
11
|
|
|
|
|
|
|
nullable is_nullable |
12
|
|
|
|
|
|
|
ordinal_position type_name foo |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
mysql_values mysql_type_name ) ] ); |
15
|
|
|
|
|
|
|
|
16
|
31
|
|
|
|
|
1272
|
__PACKAGE__->mk_accessors( qw( name table column_attributes ), @{ __PACKAGE__->column_attributes } ); |
|
31
|
|
|
|
|
148
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
|
20
|
31
|
|
|
31
|
|
27326
|
use overload '""' => 'name'; |
|
31
|
|
|
|
|
78
|
|
|
31
|
|
|
|
|
315
|
|
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
*order = \&ordinal_position; |
23
|
|
|
|
|
|
|
*digits = \&decimal_digits; |
24
|
|
|
|
|
|
|
*size = \&column_size; |
25
|
|
|
|
|
|
|
*default = \&column_def; |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=head1 NAME |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
Class::DBI::FormBuilder::Meta::Column |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=head1 DESCRIPTION |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
Access to column metadata. |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=head1 METHODS |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=over 4 |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=item new($table, $name, $meta) |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
Returns a new meta object for the column. |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
Stringifies to the column's C. |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=cut |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub new |
48
|
|
|
|
|
|
|
{ |
49
|
0
|
|
|
0
|
1
|
|
my ($proto, $table, $name, $meta) = @_; |
50
|
|
|
|
|
|
|
|
51
|
0
|
|
0
|
|
|
|
my $self = bless { table => $table, # reference to table meta object |
52
|
|
|
|
|
|
|
name => $name, |
53
|
|
|
|
|
|
|
%$meta, |
54
|
|
|
|
|
|
|
}, ref($proto) || $proto; |
55
|
|
|
|
|
|
|
|
56
|
0
|
|
|
|
|
|
return $self; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=item table |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
Returns the L object associated with this column. |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=back |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=head2 Column attribute accessors |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=over 4 |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=item name |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=item order |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=item ordinal_position |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
Alias for C. |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=item digits |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=item decimal_digits |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
Alias for C. |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=item size |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=item column_size |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
Alias for C. |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=item default |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=item column_def |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
Alias for C. |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=item nullable |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=item is_nullable |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=item type |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=item type_name |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
Alias for C. |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=item mysql_values |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=item mysql_type_name |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=cut |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
sub type |
112
|
|
|
|
|
|
|
{ |
113
|
0
|
|
|
0
|
1
|
|
my ( $self ) = @_; |
114
|
|
|
|
|
|
|
|
115
|
0
|
|
0
|
|
|
|
my $type = $self->type_name || die "No type_name for $self"; |
116
|
|
|
|
|
|
|
|
117
|
0
|
|
|
|
|
|
return lc $type; |
118
|
|
|
|
|
|
|
} |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=item options |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
Returns the possible values for an enumerated column, and whether the |
123
|
|
|
|
|
|
|
column can store multiple value. |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
Currently only implemented for MySQL C (multiple is false) and |
126
|
|
|
|
|
|
|
C (multiple is true) column types, but should be easy to support |
127
|
|
|
|
|
|
|
other databases that offer similar column types. |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=back |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=cut |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
sub options |
134
|
|
|
|
|
|
|
{ |
135
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
136
|
|
|
|
|
|
|
|
137
|
0
|
|
|
|
|
|
my $type = $self->type; |
138
|
|
|
|
|
|
|
|
139
|
0
|
0
|
|
|
|
|
my $series = $type =~ /^(?:set|enum)$/o ? $self->mysql_values : []; |
140
|
|
|
|
|
|
|
|
141
|
0
|
0
|
|
|
|
|
my $multiple = 1 if $type eq 'set'; |
142
|
|
|
|
|
|
|
|
143
|
0
|
|
|
|
|
|
return $series, $multiple; |
144
|
|
|
|
|
|
|
} |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
1; |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
__END__ |