Eval.pm

filter: Statementstmt 90.6% 68 / 75 Branchbran 88.2% 30 / 34 Conditioncond 36.6% 11 / 30 MC/DCmcdc 5.2% 1 / 19 Subroutinesub 77.4% 24 / 31 Podpod 100% 5 / 5 totaltotal 71.6% 139 / 194 CC 29 SCAR 19.4
CC
29
Cov
78%
capability
17.6
new
10.4
param
3.2
CRAP 6.9
« Statement/TermFactory.pm ↑ Summary Statement/Functions.pm »
1 package SQL::Eval;
2  
3 #########################################################################
4 #
5 # This module is copyright (c), 2001,2005 by Jeff Zucker.
6 # This module is copyright (c), 2007-2020 by Jens Rehsack.
7 # All rights reserved.
8 #
9 # It may be freely distributed under the same terms as Perl itself.
10 #
11 # See below for help (search for SYNOPSIS)
12 #########################################################################
13  
14 16 require 5.008;
15 16 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 16 ▶use warnings FATAL => "all";
Subroutine BEGIN: called CC=1 SCAR=0.0
17 16 ▶use vars qw($VERSION);
Subroutine BEGIN: called CC=1 SCAR=0.0
18  
19 16 $VERSION = '1.414';
20  
21 16 ▶use Carp qw(croak);
Subroutine BEGIN: called CC=1 SCAR=0.0
22  
23 sub new($)
24 4643 ▶{
Subroutine new: called CC=2 SCAR=7.6
Pod documented
25 4643 my ( $proto, $attr ) = @_;
26 4643 my ($self) = {%$attr};
27 4643 ▶ bless( $self, ( ref($proto) || $proto ) );
Condition33%1/3
ref $proto || $proto
l!l&&r!l&&!r
046430
MC/DC0%0/2
ref $proto || $proto
ref $proto $proto
Truth table33%1/3
A || B
A= ref $protoB= $proto
ABresult
1X1
011
000
28 }
29  
30 sub param($;$)
31 12242 ▶{
Subroutine param: called CC=3 SCAR=11.7
Pod documented
32 12242 ▶ $_[1] < 0 and croak "Illegal parameter number: $_[1]";
Branch: 1 branch
BranchTrueFalseTotal
$_[1] < 0 and croak("Illegal parameter number: $_[1]") 0 12242 12242
33 12242 ▶ @_ == 3 and return $_[0]->{params}->[ $_[1] ] = $_[2];
Branch: 1 branch
BranchTrueFalseTotal
@_ == 3 and return $_[0]{"params"}[$_[1]] = $_[2] 0 12242 12242
34 12242 $_[0]->{params}->[ $_[1] ];
35 }
36  
37 sub params(;$)
38 4443 ▶{
Subroutine params: called CC=2 SCAR=6.9
Pod documented
39 4443 ▶ @_ == 2 and return $_[0]->{params} = $_[1];
Branch: 1 branch
BranchTrueFalseTotal
@_ == 2 and return $_[0]{"params"} = $_[1] 4442 1 4443
40 1 $_[0]->{params};
41 }
42  
43 4808 ▶sub table($) { $_[0]->{tables}->{ $_[1] } }
Subroutine table: called CC=1 SCAR=0.0
Pod documented
44  
45 1 ▶sub column($$) { $_[0]->table( $_[1] )->column( $_[2] ) }
Subroutine column: called CC=1 SCAR=0.0
Pod documented
46  
47 224 ▶sub _gen_access_fastpath($) { $_[0]->table( $_[1] )->_gen_access_fastpath() }
Subroutine _gen_access_fastpath: called CC=1 SCAR=0.0
48  
49 package SQL::Eval::Table;
50  
51 16 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
52 16 ▶use warnings FATAL => "all";
Subroutine BEGIN: called CC=1 SCAR=0.0
53  
54 16 ▶use Carp qw(croak);
Subroutine BEGIN: called CC=1 SCAR=0.0
55 16 ▶use Params::Util qw(_ARRAY0 _HASH0);
Subroutine BEGIN: called CC=1 SCAR=0.0
56  
57 sub new($)
58 83 ▶{
Subroutine new: called CC=8 SCAR=23.4
59 83 my ( $proto, $attr ) = @_;
60 83 my ($self) = {%$attr};
61  
62 83 ▶ defined( $self->{col_names} ) and defined( _ARRAY0( $self->{col_names} ) )
Branch: 1 branch
BranchTrueFalseTotal
defined $self->{"col_names"} and defined &_ARRAY0($self->{"col_names"}) or croak("attribute 'col_names' must be defined as an array") 83 0 83
Condition33%1/3
defined $self->{"col_names"} and defined &_ARRAY0($self->{"col_names"})
!ll&&!rl&&r
0083
MC/DC0%0/2
defined $self->{"col_names"} and defined &_ARRAY0($self->{"col_names"})
defined $self->{"col_names"} defined &_ARRAY0($self->{"col_names"})
Truth table33%1/3
A and B
A= defined $self->{"col_names"}B= defined &_ARRAY0($self->{"col_names"})
ABresult
0X0
100
111
63 or croak("attribute 'col_names' must be defined as an array");
64 83 ▶ exists( $self->{col_nums} ) or $self->{col_nums} = _map_colnums( $self->{col_names} );
Branch: 1 branch
BranchTrueFalseTotal
exists $self->{"col_nums"} or $self->{"col_nums"} = _map_colnums($self->{"col_names"}) 45 38 83
65 83 ▶ defined( $self->{col_nums} ) and defined( _HASH0( $self->{col_nums} ) )
Branch: 1 branch
BranchTrueFalseTotal
defined $self->{"col_nums"} and defined &_HASH0($self->{"col_nums"}) or croak("attribute 'col_nums' must be defined as a hash") 83 0 83
Condition33%1/3
defined $self->{"col_nums"} and defined &_HASH0($self->{"col_nums"})
!ll&&!rl&&r
0083
MC/DC0%0/2
defined $self->{"col_nums"} and defined &_HASH0($self->{"col_nums"})
defined $self->{"col_nums"} defined &_HASH0($self->{"col_nums"})
Truth table33%1/3
A and B
A= defined $self->{"col_nums"}B= defined &_HASH0($self->{"col_nums"})
ABresult
0X0
100
111
66 or croak("attribute 'col_nums' must be defined as a hash");
67  
68 83 ▶ $self->{capabilities} = {} unless ( defined( $self->{capabilities} ) );
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"capabilities"} 45 38 83
69 83 ▶ bless( $self, ( ref($proto) || $proto ) );
Condition33%1/3
ref $proto || $proto
l!l&&r!l&&!r
0830
MC/DC0%0/2
ref $proto || $proto
ref $proto $proto
Truth table33%1/3
A || B
A= ref $protoB= $proto
ABresult
1X1
011
000
70 }
71  
72 sub _map_colnums
73 73 ▶{
Subroutine _map_colnums: called CC=2 SCAR=6.9
74 73 my $col_names = $_[0];
75 73 my %col_nums;
76 73 $col_nums{ $col_names->[$_] } = $_ for ( 0 .. scalar @$col_names - 1 );
77 73 \%col_nums;
78 }
79  
80 1 ▶sub row() { $_[0]->{row} }
Subroutine row: called CC=1 SCAR=0.0
81 2 ▶sub column($) { $_[0]->{row}->[ $_[0]->column_num( $_[1] ) ] }
Subroutine column: called CC=1 SCAR=0.0
82 12994 ▶sub column_num($) { $_[0]->{col_nums}->{ $_[1] }; }
Subroutine column_num: called CC=1 SCAR=0.0
83 0 ▶sub col_nums() { $_[0]->{col_nums} }
Subroutine col_nums: not called CC=1 SCAR=6.9
84 4711 ▶sub col_names() { $_[0]->{col_names}; }
Subroutine col_names: called CC=1 SCAR=0.0
85  
86 sub _gen_access_fastpath($)
87 394 ▶{
Subroutine _gen_access_fastpath: called CC=3 SCAR=11.0
88 394 my ($self) = @_;
89  
90 $self->can("column") == SQL::Eval::Table->can("column")
91 && $self->can("column_num") == SQL::Eval::Table->can("column_num")
92 16951 ▶ ? sub { $self->{row}->[ $self->{col_nums}->{ $_[0] } ] }
Subroutine __ANON__: called CC=1 SCAR=0.0
93 394 ▶ : sub { $self->column( $_[0] ) };
Subroutine __ANON__: called CC=1 SCAR=0.0
Branch: 1 branch
BranchTrueFalseTotal
$self->can('column') == 'SQL::Eval::Table'->can('column') && $self->can('column_num') == 'SQL::Eval::Table'->can('column_num') ? : 224 170 394
Condition66%2/3
$self->can("column") == "SQL::Eval::Table"->can("column") and $self->can("column_num") == "SQL::Eval::Table"->can("column_num")
!ll&&!rl&&r
1700224
MC/DC50%1/2
$self->can("column") == "SQL::Eval::Table"->can("column") and $self->can("column_num") == "SQL::Eval::Table"->can("column_num")
$self->can("column") == "SQL::Eval::Table"->can("column") $self->can("column_num") == "SQL::Eval::Table"->can("column_num")
Truth table66%2/3
A and B
A= $self->can("column") == "SQL::Eval::Table"->can("column")B= $self->can("column_num") == "SQL::Eval::Table"->can("column_num")
ABresult
0X0
100
111
94 }
95  
96 sub capability($)
97 8709 ▶{
Subroutine capability: called CC=15 SCAR=28.7
98 8709 my ( $self, $capname ) = @_;
99 8709 ▶ exists $self->{capabilities}->{$capname} and return $self->{capabilities}->{$capname};
Branch: 1 branch
BranchTrueFalseTotal
exists $self->{"capabilities"}{$capname} and return $self->{"capabilities"}{$capname} 8652 57 8709
100  
101 $capname eq "insert_new_row"
102 57 ▶ and $self->{capabilities}->{insert_new_row} = $self->can("insert_new_row");
Branch: 1 branch
BranchTrueFalseTotal
$capname eq "insert_new_row" and $self->{"capabilities"}{"insert_new_row"} = $self->can("insert_new_row") 32 25 57
103 $capname eq "delete_one_row"
104 57 ▶ and $self->{capabilities}->{delete_one_row} = $self->can("delete_one_row");
Branch: 1 branch
BranchTrueFalseTotal
$capname eq "delete_one_row" and $self->{"capabilities"}{"delete_one_row"} = $self->can("delete_one_row") 3 54 57
105 $capname eq "delete_current_row"
106 and $self->{capabilities}->{delete_current_row} =
107 57 ▶ ( $self->can("delete_current_row") and $self->capability("inplace_delete") );
Branch: 1 branch
BranchTrueFalseTotal
$capname eq "delete_current_row" and $self->{"capabilities"}{"delete_current_row"} = $self->can("delete_current_row") && $self->capability("inplace_delete") 3 54 57
Condition33%1/3
$self->can('delete_current_row') && $self->capability('inplace_delete')
!ll&&!rl&&r
003
MC/DC0%0/2
$self->can('delete_current_row') && $self->capability('inplace_delete')
$self->can('delete_current_row') $self->capability('inplace_delete')
Truth table33%1/3
A && B
A= $self->can('delete_current_row')B= $self->capability('inplace_delete')
ABresult
0X0
100
111
108 $capname eq "update_one_row"
109 57 ▶ and $self->{capabilities}->{update_one_row} = $self->can("update_one_row");
Branch: 1 branch
BranchTrueFalseTotal
$capname eq "update_one_row" and $self->{"capabilities"}{"update_one_row"} = $self->can("update_one_row") 4 53 57
110 $capname eq "update_current_row"
111 and $self->{capabilities}->{update_current_row} =
112 57 ▶ ( $self->can("update_current_row") and $self->capability("inplace_update") );
Branch: 1 branch
BranchTrueFalseTotal
$capname eq "update_current_row" and $self->{"capabilities"}{"update_current_row"} = $self->can("update_current_row") && $self->capability("inplace_update") 4 53 57
Condition33%1/3
$self->can('update_current_row') && $self->capability('inplace_update')
!ll&&!rl&&r
004
MC/DC0%0/2
$self->can('update_current_row') && $self->capability('inplace_update')
$self->can('update_current_row') $self->capability('inplace_update')
Truth table33%1/3
A && B
A= $self->can('update_current_row')B= $self->capability('inplace_update')
ABresult
0X0
100
111
113 $capname eq "update_specific_row"
114 57 ▶ and $self->{capabilities}->{update_specific_row} = $self->can("update_specific_row");
Branch: 1 branch
BranchTrueFalseTotal
$capname eq "update_specific_row" and $self->{"capabilities"}{"update_specific_row"} = $self->can("update_specific_row") 4 53 57
115  
116 $capname eq "rowwise_update"
117 and $self->{capabilities}->{rowwise_update} = (
118 57 ▶ $self->capability("update_one_row")
Branch: 1 branch
BranchTrueFalseTotal
$capname eq "rowwise_update" and $self->{"capabilities"}{"rowwise_update"} = $self->capability("update_one_row") || $self->capability("update_current_row") || $self->capability("update_specific_row") 4 53 57
Condition33%2/6
$self->capability('update_one_row') || $self->capability('update_current_row') || $self->capability('update_specific_row')
l!l&&r!l&&!r
400
$self->capability("update_one_row") or $self->capability("update_current_row")
l!l&&r!l&&!r
040
MC/DC0%0/3
$self->capability('update_one_row') || $self->capability('update_current_row') || $self->capability('update_specific_row')
$self->capability("update_one_row") $self->capability("update_current_row") $self->capability('update_specific_row')
Truth table0%0/4
A or B || C
A= $self->capability("update_one_row")B= $self->capability("update_current_row")C= $self->capability('update_specific_row')
ABCresult
1XX1
01X1
0011
0000
119 or $self->capability("update_current_row")
120 or $self->capability("update_specific_row")
121 );
122 $capname eq "rowwise_delete"
123 and $self->{capabilities}->{rowwise_delete} = (
124 57 ▶ $self->capability("delete_one_row")
Branch: 1 branch
BranchTrueFalseTotal
$capname eq "rowwise_delete" and $self->{"capabilities"}{"rowwise_delete"} = $self->capability("delete_one_row") || $self->capability("delete_current_row") 3 54 57
Condition33%1/3
$self->capability('delete_one_row') || $self->capability('delete_current_row')
l!l&&r!l&&!r
030
MC/DC0%0/2
$self->capability('delete_one_row') || $self->capability('delete_current_row')
$self->capability('delete_one_row') $self->capability('delete_current_row')
Truth table33%1/3
A || B
A= $self->capability('delete_one_row')B= $self->capability('delete_current_row')
ABresult
1X1
011
000
125 or $self->capability("delete_current_row")
126 );
127  
128 57 $self->{capabilities}->{$capname};
129 }
130  
131 0 ▶sub drop ($$) { croak "Abstract method " . ref( $_[0] ) . "::drop called" }
Subroutine drop: not called CC=1 SCAR=6.9
132 0 ▶sub fetch_row ($$) { croak "Abstract method " . ref( $_[0] ) . "::fetch_row called" }
Subroutine fetch_row: not called CC=1 SCAR=6.9
133 0 ▶sub push_row ($$$) { croak "Abstract method " . ref( $_[0] ) . "::push_row called" }
Subroutine push_row: not called CC=1 SCAR=6.9
134 0 ▶sub push_names ($$$) { croak "Abstract method " . ref( $_[0] ) . "::push_names called" }
Subroutine push_names: not called CC=1 SCAR=6.9
135 0 ▶sub truncate ($$) { croak "Abstract method " . ref( $_[0] ) . "::truncate called" }
Subroutine truncate: not called CC=1 SCAR=6.9
136 0 ▶sub seek ($$$$) { croak "Abstract method " . ref( $_[0] ) . "::seek called" }
Subroutine seek: not called CC=1 SCAR=6.9
137  
138 16 1;
139  
140 __END__
« Statement/TermFactory.pm ↑ Summary Statement/Functions.pm »