| 1 | package Alzabo::Create::ColumnDefinition; | ||||||||||||||||||||
| 2 | |||||||||||||||||||||
| 3 | 9 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 4 | 9 | ▶ | use vars qw($VERSION); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 5 | |||||||||||||||||||||
| 6 | 9 | ▶ | use Alzabo::Create; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 7 | 9 | ▶ | use Alzabo::Exceptions ( abbr => 'params_exception' ); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 8 | |||||||||||||||||||||
| 9 | 9 | ▶ | use Params::Validate qw( :all ); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 10 | Params::Validate::validation_options | ||||||||||||||||||||
| 11 | 0 | ▶ | ( on_fail => sub { params_exception join '', @_ } ); | ||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||
| 12 | |||||||||||||||||||||
| 13 | 9 | ▶ | use base qw(Alzabo::ColumnDefinition); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 14 | |||||||||||||||||||||
| 15 | 9 | $VERSION = 2.0; | |||||||||||||||||||
| 16 | |||||||||||||||||||||
| 17 | 9 | 1; | |||||||||||||||||||
| 18 | |||||||||||||||||||||
| 19 | sub new | ||||||||||||||||||||
| 20 | 0 | ▶ | { | ||||||||||||||||||
|
Subroutine
new: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||
| 21 | 0 | my $proto = shift; | |||||||||||||||||||
| 22 | 0 | ▶ | my $class = ref $proto || $proto; | ||||||||||||||||||
|
Condition0%0/3
ref $proto || $proto
MC/DC0%0/2
ref $proto || $proto
ref $proto
$proto
Truth table0%0/3
A || B
A= ref $protoB= $proto
| |||||||||||||||||||||
| 23 | |||||||||||||||||||||
| 24 | 0 | my $self = bless {}, $class; | |||||||||||||||||||
| 25 | |||||||||||||||||||||
| 26 | 0 | $self->_init(@_); | |||||||||||||||||||
| 27 | |||||||||||||||||||||
| 28 | 0 | return $self; | |||||||||||||||||||
| 29 | } | ||||||||||||||||||||
| 30 | |||||||||||||||||||||
| 31 | sub _init | ||||||||||||||||||||
| 32 | 0 | ▶ | { | ||||||||||||||||||
|
Subroutine
_init: not called CC=3 SCAR=24.8
| |||||||||||||||||||||
| 33 | 0 | my $self = shift; | |||||||||||||||||||
| 34 | |||||||||||||||||||||
| 35 | 0 | validate( @_, { owner => { isa => 'Alzabo::Create::Column' }, | |||||||||||||||||||
| 36 | type => { type => SCALAR }, | ||||||||||||||||||||
| 37 | length => { type => UNDEF | SCALAR, | ||||||||||||||||||||
| 38 | optional => 1 }, | ||||||||||||||||||||
| 39 | precision => { type => UNDEF | SCALAR, | ||||||||||||||||||||
| 40 | optional => 1 }, | ||||||||||||||||||||
| 41 | } ); | ||||||||||||||||||||
| 42 | 0 | my %p = @_; | |||||||||||||||||||
| 43 | |||||||||||||||||||||
| 44 | $p{type} = | ||||||||||||||||||||
| 45 | 0 | $p{owner}->table->schema->rules->validate_column_type( $p{type}, $p{owner}->table ); | |||||||||||||||||||
| 46 | 0 | foreach ( qw( owner type ) ) | |||||||||||||||||||
| 47 | { | ||||||||||||||||||||
| 48 | 0 | ▶ | $self->{$_} = $p{$_} if exists $p{$_}; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 49 | } | ||||||||||||||||||||
| 50 | } | ||||||||||||||||||||
| 51 | |||||||||||||||||||||
| 52 | sub alter | ||||||||||||||||||||
| 53 | 0 | ▶ | { | ||||||||||||||||||
|
Subroutine
alter: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||
| 54 | 0 | my $self = shift; | |||||||||||||||||||
| 55 | |||||||||||||||||||||
| 56 | 0 | validate( @_, { type => { type => SCALAR }, | |||||||||||||||||||
| 57 | length => { type => UNDEF | SCALAR, | ||||||||||||||||||||
| 58 | optional => 1 }, | ||||||||||||||||||||
| 59 | precision => { type => UNDEF | SCALAR, | ||||||||||||||||||||
| 60 | optional => 1 }, | ||||||||||||||||||||
| 61 | } ); | ||||||||||||||||||||
| 62 | 0 | my %p = @_; | |||||||||||||||||||
| 63 | |||||||||||||||||||||
| 64 | 0 | my $old_type = $self->{type}; | |||||||||||||||||||
| 65 | 0 | my $old_length = $self->{length}; | |||||||||||||||||||
| 66 | 0 | my $old_precision = $self->{precision}; | |||||||||||||||||||
| 67 | |||||||||||||||||||||
| 68 | 0 | ▶ | $self->{length} = $p{length} if exists $p{length}; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 69 | 0 | ▶ | $self->{precision} = $p{precision} if exists $p{precision}; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 70 | |||||||||||||||||||||
| 71 | eval | ||||||||||||||||||||
| 72 | 0 | { | |||||||||||||||||||
| 73 | $self->{type} = | ||||||||||||||||||||
| 74 | 0 | $self->owner->table->schema->rules->validate_column_type($p{type}, $self->owner->table); | |||||||||||||||||||
| 75 | 0 | ▶ | $self->owner->table->schema->rules->validate_primary_key($self->owner) | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 76 | if $self->owner->is_primary_key; | ||||||||||||||||||||
| 77 | 0 | $self->owner->table->schema->rules->validate_column_length($self->owner); | |||||||||||||||||||
| 78 | }; | ||||||||||||||||||||
| 79 | 0 | ▶ | if ($@) | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 80 | { | ||||||||||||||||||||
| 81 | 0 | $self->{type} = $old_type; | |||||||||||||||||||
| 82 | 0 | $self->{length} = $old_length; | |||||||||||||||||||
| 83 | 0 | $self->{precision} = $old_precision; | |||||||||||||||||||
| 84 | |||||||||||||||||||||
| 85 | 0 | rethrow_exception($@); | |||||||||||||||||||
| 86 | } | ||||||||||||||||||||
| 87 | } | ||||||||||||||||||||
| 88 | |||||||||||||||||||||
| 89 | sub set_type | ||||||||||||||||||||
| 90 | 0 | ▶ | { | ||||||||||||||||||
|
Subroutine
set_type: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||
| 91 | 0 | my $self = shift; | |||||||||||||||||||
| 92 | |||||||||||||||||||||
| 93 | 0 | validate_pos( @_, { type => SCALAR } ); | |||||||||||||||||||
| 94 | 0 | my $type = shift; | |||||||||||||||||||
| 95 | |||||||||||||||||||||
| 96 | 0 | my $old_type = $self->{type}; | |||||||||||||||||||
| 97 | eval | ||||||||||||||||||||
| 98 | 0 | { | |||||||||||||||||||
| 99 | $self->{type} = | ||||||||||||||||||||
| 100 | 0 | $self->owner->table->schema->rules->validate_column_type($type, $self->owner->table); | |||||||||||||||||||
| 101 | $self->owner->table->schema->rules->validate_primary_key($self->owner) | ||||||||||||||||||||
| 102 | 0 | ▶ | if eval { $self->owner->is_primary_key }; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 103 | # eval ^^ cause if we're creating the column its not in the table yet | ||||||||||||||||||||
| 104 | }; | ||||||||||||||||||||
| 105 | 0 | ▶ | if ($@) | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 106 | { | ||||||||||||||||||||
| 107 | 0 | $self->{type} = $old_type; | |||||||||||||||||||
| 108 | |||||||||||||||||||||
| 109 | 0 | rethrow_exception($@); | |||||||||||||||||||
| 110 | } | ||||||||||||||||||||
| 111 | } | ||||||||||||||||||||
| 112 | |||||||||||||||||||||
| 113 | sub set_length | ||||||||||||||||||||
| 114 | 0 | ▶ | { | ||||||||||||||||||
|
Subroutine
set_length: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||
| 115 | 0 | my $self = shift; | |||||||||||||||||||
| 116 | |||||||||||||||||||||
| 117 | 0 | validate( @_, { length => { type => UNDEF | SCALAR }, | |||||||||||||||||||
| 118 | precision => { type => UNDEF | SCALAR, | ||||||||||||||||||||
| 119 | optional => 1 } } ); | ||||||||||||||||||||
| 120 | 0 | my %p = @_; | |||||||||||||||||||
| 121 | |||||||||||||||||||||
| 122 | 0 | my $old_length = $self->{length}; | |||||||||||||||||||
| 123 | 0 | my $old_precision = $self->{precision}; | |||||||||||||||||||
| 124 | 0 | $self->{length} = $p{length}; | |||||||||||||||||||
| 125 | 0 | ▶ | $self->{precision} = $p{precision} if exists $p{precision}; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 126 | |||||||||||||||||||||
| 127 | eval | ||||||||||||||||||||
| 128 | 0 | { | |||||||||||||||||||
| 129 | 0 | $self->owner->table->schema->rules->validate_column_length($self->owner); | |||||||||||||||||||
| 130 | }; | ||||||||||||||||||||
| 131 | 0 | ▶ | if ($@) | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 132 | { | ||||||||||||||||||||
| 133 | 0 | $self->{length} = $old_length; | |||||||||||||||||||
| 134 | 0 | $self->{precision} = $old_precision; | |||||||||||||||||||
| 135 | |||||||||||||||||||||
| 136 | 0 | rethrow_exception($@); | |||||||||||||||||||
| 137 | } | ||||||||||||||||||||
| 138 | } | ||||||||||||||||||||
| 139 | |||||||||||||||||||||
| 140 | 9 | 1; | |||||||||||||||||||
| 141 | |||||||||||||||||||||
| 142 | __END__ | ||||||||||||||||||||