line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Rose::DB::Object::Metadata::Column::Varchar; |
2
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
23
|
use strict; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
99
|
|
4
|
|
|
|
|
|
|
|
5
|
3
|
|
|
3
|
|
17
|
use Carp(); |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
52
|
|
6
|
|
|
|
|
|
|
|
7
|
3
|
|
|
3
|
|
2007
|
use Rose::DB::Object::Metadata::Column::Character; |
|
3
|
|
|
|
|
9
|
|
|
3
|
|
|
|
|
1078
|
|
8
|
|
|
|
|
|
|
our @ISA = qw(Rose::DB::Object::Metadata::Column::Character); |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $VERSION = '0.803'; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
foreach my $type (__PACKAGE__->available_method_types) |
13
|
|
|
|
|
|
|
{ |
14
|
|
|
|
|
|
|
__PACKAGE__->method_maker_type($type => 'varchar'); |
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
|
17
|
7
|
|
|
7
|
1
|
45
|
sub type { 'varchar' } |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub parse_value |
20
|
|
|
|
|
|
|
{ |
21
|
0
|
|
|
0
|
1
|
|
my ($self, $db, $value) = @_; |
22
|
|
|
|
|
|
|
|
23
|
0
|
0
|
|
|
|
|
my $length = $self->length or return $value; |
24
|
|
|
|
|
|
|
|
25
|
0
|
0
|
|
|
|
|
if(length($value) > $length) |
26
|
|
|
|
|
|
|
{ |
27
|
0
|
|
|
|
|
|
my $overflow = $self->overflow; |
28
|
|
|
|
|
|
|
|
29
|
0
|
0
|
|
|
|
|
if($overflow eq 'fatal') |
|
|
0
|
|
|
|
|
|
30
|
|
|
|
|
|
|
{ |
31
|
0
|
|
|
|
|
|
local $Carp::CarpLevel = $Carp::CarpLevel + 1; |
32
|
0
|
|
|
|
|
|
Carp::croak $self->parent->class, ': Value for ', $self->name, ' is too long. Maximum ', |
33
|
0
|
0
|
|
|
|
|
"length is $length character@{[ $length == 1 ? '' : 's' ]}. ", |
34
|
|
|
|
|
|
|
"Value is ", length($value), " characters: $value"; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
elsif($overflow eq 'warn') |
37
|
|
|
|
|
|
|
{ |
38
|
0
|
|
|
|
|
|
local $Carp::CarpLevel = $Carp::CarpLevel + 1; |
39
|
0
|
|
|
|
|
|
Carp::carp $self->parent->class, ': Value for ', $self->name, ' is too long. Maximum ', |
40
|
0
|
0
|
|
|
|
|
"length is $length character@{[ $length == 1 ? '' : 's' ]}. ", |
41
|
|
|
|
|
|
|
"Value is ", length($value), " characters: $value"; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
0
|
|
|
|
|
|
return substr($value, 0, $length); |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
*format_value = \&parse_value; |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
1; |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
__END__ |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=head1 NAME |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
Rose::DB::Object::Metadata::Column::Varchar - Variable-length character column metadata. |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=head1 SYNOPSIS |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
use Rose::DB::Object::Metadata::Column::Varchar; |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
$col = Rose::DB::Object::Metadata::Column::Varchar->new(...); |
63
|
|
|
|
|
|
|
$col->make_methods(...); |
64
|
|
|
|
|
|
|
... |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=head1 DESCRIPTION |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
Objects of this class store and manipulate metadata for variable-length character columns in a database. Column metadata objects store information about columns (data type, size, etc.) and are responsible for creating object methods that manipulate column values. |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
This class inherits from L<Rose::DB::Object::Metadata::Column::Character>. Inherited methods that are not overridden will not be documented a second time here. See the L<Rose::DB::Object::Metadata::Column::Character> documentation for more information. |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=head1 METHOD MAP |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=over 4 |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=item C<get_set> |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
L<Rose::DB::Object::MakeMethods::Generic>, L<varchar|Rose::DB::Object::MakeMethods::Generic/varchar>, ... |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=item C<get> |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
L<Rose::DB::Object::MakeMethods::Generic>, L<varchar|Rose::DB::Object::MakeMethods::Generic/varchar>, ... |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=item C<get_set> |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
L<Rose::DB::Object::MakeMethods::Generic>, L<varchar|Rose::DB::Object::MakeMethods::Generic/varchar>, ... |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=back |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
See the L<Rose::DB::Object::Metadata::Column|Rose::DB::Object::Metadata::Column/"MAKING METHODS"> documentation for an explanation of this method map. |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=head1 OBJECT METHODS |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=over 4 |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=item B<parse_value DB, VALUE> |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
If C<length> is defined, returns VALUE truncated to a maximum of C<length> characters. DB is a L<Rose::DB> object that may be used as part of the parsing process. Both arguments are required. |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=item B<type> |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
Returns "varchar". |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=back |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=head1 AUTHOR |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
John C. Siracusa (siracusa@gmail.com) |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=head1 LICENSE |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
Copyright (c) 2010 by John C. Siracusa. All rights reserved. This program is |
113
|
|
|
|
|
|
|
free software; you can redistribute it and/or modify it under the same terms |
114
|
|
|
|
|
|
|
as Perl itself. |