| 1 | package Rose::DB::Object::Metadata::Column::Varchar; | ||||||||||||||
| 2 | |||||||||||||||
| 3 | 3 | ▶ | use strict; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 4 | |||||||||||||||
| 5 | 3 | ▶ | use Carp(); | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 6 | |||||||||||||||
| 7 | 3 | ▶ | use Rose::DB::Object::Metadata::Column::Character; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 8 | 3 | our @ISA = qw(Rose::DB::Object::Metadata::Column::Character); | |||||||||||||
| 9 | |||||||||||||||
| 10 | 3 | our $VERSION = '0.803'; | |||||||||||||
| 11 | |||||||||||||||
| 12 | 3 | foreach my $type (__PACKAGE__->available_method_types) | |||||||||||||
| 13 | { | ||||||||||||||
| 14 | 9 | __PACKAGE__->method_maker_type($type => 'varchar'); | |||||||||||||
| 15 | } | ||||||||||||||
| 16 | |||||||||||||||
| 17 | 7 | ▶ | sub type { 'varchar' } | ||||||||||||
|
Subroutine
type: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||
| 18 | |||||||||||||||
| 19 | sub parse_value | ||||||||||||||
| 20 | 0 | ▶ | { | ||||||||||||
|
Subroutine
parse_value: not called CC=7 SCAR=40.3
Pod
documented
| |||||||||||||||
| 21 | 0 | my ($self, $db, $value) = @_; | |||||||||||||
| 22 | |||||||||||||||
| 23 | 0 | ▶ | my $length = $self->length or return $value; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 24 | |||||||||||||||
| 25 | 0 | ▶ | if(length($value) > $length) | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 26 | { | ||||||||||||||
| 27 | 0 | my $overflow = $self->overflow; | |||||||||||||
| 28 | |||||||||||||||
| 29 | 0 | ▶ | if($overflow eq 'fatal') | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 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 | ▶ | "length is $length character@{[ $length == 1 ? '' : 's' ]}. ", | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 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 | ▶ | "length is $length character@{[ $length == 1 ? '' : 's' ]}. ", | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 41 | "Value is ", length($value), " characters: $value"; | ||||||||||||||
| 42 | } | ||||||||||||||
| 43 | } | ||||||||||||||
| 44 | |||||||||||||||
| 45 | 0 | return substr($value, 0, $length); | |||||||||||||
| 46 | } | ||||||||||||||
| 47 | |||||||||||||||
| 48 | 3 | *format_value = \&parse_value; | |||||||||||||
| 49 | |||||||||||||||
| 50 | 3 | 1; | |||||||||||||
| 51 | |||||||||||||||
| 52 | __END__ | ||||||||||||||