Geoffrey/Action/Constraint/PrimaryKey.pm

filter: Statementstmt 82.2% 37 / 45 Branchbran 50.0% 4 / 8 Conditioncond 50.0% 1 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 100% 10 / 10 Podpod 100% 4 / 4 totaltotal 80.0% 56 / 70 CC 6 SCAR 6.7
CC
6
Cov
76%
add
3.2
alter
2.3
list_from_schema
2.3
CRAP 2.0
« Geoffrey/Write.pm ↑ Summary Geoffrey/Role/Changelog.pm »
1 package Geoffrey::Action::Constraint::PrimaryKey;
2  
3 6 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 6 ▶use 5.016;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 6 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 6 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 6 ▶use Time::HiRes qw/ time /;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 6 $Geoffrey::Action::Constraint::PrimaryKey::VERSION = '0.000206';
10  
11 6 ▶use parent 'Geoffrey::Role::Action';
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 2 ▶sub add {
Subroutine add: called CC=3 SCAR=11.7
Pod documented
14 2 my ( $self, $s_table_name, $hr_params ) = @_;
15 2 ▶ if ( !$self->converter->primary_key ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->converter->primary_key) 0 2 2
16 0 require Geoffrey::Exception::NotSupportedException;
17 0 Geoffrey::Exception::NotSupportedException::throw_primarykey( 'add', $self->converter );
18 }
19 2 my $gentime = time;
20 2 $gentime =~ s/\.//g;
21 2 ▶ $hr_params->{name} ||= q~pk_~ . $s_table_name . q~_~ . $gentime;
Condition50%1/2
$hr_params->{"name"} ||= 'pk_' . $s_table_name . '_' . $gentime
l!l
20
MC/DC0%0/1
$hr_params->{"name"} ||= 'pk_' . $s_table_name . '_' . $gentime
$hr_params->{"name"}
Truth table50%1/2
A
A= $hr_params->{"name"}
Aresult
11
00
22 2 require Geoffrey::Utils;
23 return Geoffrey::Utils::replace_spare( $self->converter->primary_key->add,
24 2 [ $hr_params->{name}, ( join q/,/, @{ $hr_params->{columns} } ) ] );
25 }
26  
27 1 ▶sub alter {
Subroutine alter: called CC=2 SCAR=8.4
Pod documented
28 1 my ( $self, $s_table_name, $hr_params ) = @_;
29 1 ▶ if ( !$self->converter->primary_key ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->converter->primary_key) 0 1 1
30 0 require Geoffrey::Exception::NotSupportedException;
31 0 Geoffrey::Exception::NotSupportedException::throw_primarykey( 'alter', $self->converter );
32 }
33 return [
34 1 $self->drop( $s_table_name, $hr_params ),
35 $self->add( $s_table_name, $hr_params ),
36 ];
37 }
38  
39 2 ▶sub drop {
Subroutine drop: called CC=2 SCAR=7.9
Pod documented
40 2 my ( $self, $table, $name, $schema ) = @_;
41 2 ▶ if ( !$self->converter->primary_key ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->converter->primary_key) 0 2 2
42 0 require Geoffrey::Exception::NotSupportedException;
43 0 Geoffrey::Exception::NotSupportedException::throw_primarykey( 'drop', $self->converter );
44 }
45 2 require Geoffrey::Utils;
46 2 return Geoffrey::Utils::replace_spare( $self->converter->primary_key->drop($schema),
47 [ $table, $name ] );
48 }
49  
50 3 ▶sub list_from_schema {
Subroutine list_from_schema: called CC=2 SCAR=8.4
Pod documented
51 3 my ( $self, $schema ) = @_;
52 3 ▶ if ( !$self->converter->primary_key ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->converter->primary_key) 0 3 3
53 0 require Geoffrey::Exception::NotSupportedException;
54 0 Geoffrey::Exception::NotSupportedException::throw_primarykey( 'list', $self->converter );
55 }
56 3 return $self->converter->primary_key_information(
57 $self->do_arrayref( $self->converter->primary_key->list($schema), [] ),
58 );
59 }
60  
61 6 1;
62  
63 __END__
« Geoffrey/Write.pm ↑ Summary Geoffrey/Role/Changelog.pm »