| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
8
|
|
|
8
|
|
42
|
use warnings; |
|
|
8
|
|
|
|
|
12
|
|
|
|
8
|
|
|
|
|
330
|
|
|
2
|
8
|
|
|
8
|
|
36
|
use strict; |
|
|
8
|
|
|
|
|
11
|
|
|
|
8
|
|
|
|
|
423
|
|
|
3
|
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
package Jifty::DBI::Column; |
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
|
7
|
8
|
|
|
8
|
|
37
|
use base qw/Class::Accessor::Fast Jifty::DBI::HasFilters/; |
|
|
8
|
|
|
|
|
18
|
|
|
|
8
|
|
|
|
|
4062
|
|
|
8
|
|
|
|
|
|
|
use UNIVERSAL::require; |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
__PACKAGE__->mk_accessors qw/ |
|
11
|
|
|
|
|
|
|
name |
|
12
|
|
|
|
|
|
|
type |
|
13
|
|
|
|
|
|
|
default |
|
14
|
|
|
|
|
|
|
readable writable |
|
15
|
|
|
|
|
|
|
max_length |
|
16
|
|
|
|
|
|
|
mandatory |
|
17
|
|
|
|
|
|
|
virtual |
|
18
|
|
|
|
|
|
|
distinct |
|
19
|
|
|
|
|
|
|
sort_order |
|
20
|
|
|
|
|
|
|
refers_to by |
|
21
|
|
|
|
|
|
|
alias_for_column |
|
22
|
|
|
|
|
|
|
aliased_as |
|
23
|
|
|
|
|
|
|
since until |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
label hints render_as |
|
26
|
|
|
|
|
|
|
valid_values |
|
27
|
|
|
|
|
|
|
indexed |
|
28
|
|
|
|
|
|
|
autocompleted |
|
29
|
|
|
|
|
|
|
_validator |
|
30
|
|
|
|
|
|
|
_checked_for_validate_sub |
|
31
|
|
|
|
|
|
|
record_class |
|
32
|
|
|
|
|
|
|
/; |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=head1 NAME |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
Jifty::DBI::Column |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
This class encapsulate's a single column in a Jifty::DBI::Record table |
|
42
|
|
|
|
|
|
|
description. It replaces the _accessible method in |
|
43
|
|
|
|
|
|
|
L<Jifty::DBI::Record>. |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
It has the following accessors: C<name type default validator boolean |
|
46
|
|
|
|
|
|
|
refers_to readable writable length>. |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=cut |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub is_numeric { |
|
51
|
|
|
|
|
|
|
my $self = shift; |
|
52
|
|
|
|
|
|
|
if ( $self->type =~ /INT|NUMERIC|DECIMAL|REAL|DOUBLE|FLOAT/i ) { |
|
53
|
|
|
|
|
|
|
return 1; |
|
54
|
|
|
|
|
|
|
} |
|
55
|
|
|
|
|
|
|
return 0; |
|
56
|
|
|
|
|
|
|
} |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub validator { |
|
59
|
|
|
|
|
|
|
my $self = shift; |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
if ( @_ ) { |
|
62
|
|
|
|
|
|
|
$self->_validator( shift ); |
|
63
|
|
|
|
|
|
|
} |
|
64
|
|
|
|
|
|
|
elsif ( not $self->_checked_for_validate_sub and not $self->_validator ) { |
|
65
|
|
|
|
|
|
|
my $name = ( $self->aliased_as ? $self->aliased_as : $self->name ); |
|
66
|
|
|
|
|
|
|
my $can = $self->record_class->can( "validate_" . $name ); |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
$self->_validator( $can ) if $can; |
|
69
|
|
|
|
|
|
|
$self->_checked_for_validate_sub( 1 ); |
|
70
|
|
|
|
|
|
|
} |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
return $self->_validator; |
|
73
|
|
|
|
|
|
|
} |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
# Aliases for compatibility with searchbuilder code |
|
76
|
|
|
|
|
|
|
*read = \&readable; |
|
77
|
|
|
|
|
|
|
*write = \&writable; |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
sub length { Carp::croak('$column->length is no longer supported; use $column->max_length instead') } |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
1; |