Fast/Result.pm

filter: Statementstmt 96.8% 62 / 64 Branchbran 75.0% 12 / 16 Conditioncond 71.4% 5 / 7 MC/DCmcdc 50.0% 2 / 4 Subroutinesub 90.0% 9 / 10 Podpod 85.7% 6 / 7 totaltotal 88.8% 96 / 108 CC 12 SCAR 10.9
CC
12
Cov
91%
all
5.2
array
3.0
hash
3.0
CRAP 3.0
« Fast/Output.pm ↑ Summary Fast/Cache/Redis.pm »
1 package DBIx::Fast::Result;
2  
3 38 ▶use v5.38;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 38 ▶use Object::Pad 0.807;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 38 our $VERSION = '0.22';
7  
8 class DBIx::Fast::Result {
9  
10 0 ▶ field $sth :param :reader;
Subroutine sth: not called CC=1 SCAR=2.6
Pod undocumented
11 4 field $count :reader = 0;
12  
13 4 ▶ method hash () {
Subroutine count: called CC=1 SCAR=0.0
Subroutine hash: called CC=3 SCAR=11.0
Pod documented
Pod documented
14 9 ▶ return undef unless $sth; # prepare failed under RaiseError => 0
Branch: 1 branch
BranchTrueFalseTotal
unless $sth 1 8 9
15 8 my $row = $sth->fetchrow_hashref;
16 8 ▶ $count++ if $row;
Branch: 1 branch
BranchTrueFalseTotal
if $row 7 1 8
17 8 return $row;
18 38 }
19
20 19 ▶ method array () {
Subroutine array: called CC=3 SCAR=11.0
Pod documented
21 19 ▶ return unless $sth; # prepare failed under RaiseError => 0
Branch: 1 branch
BranchTrueFalseTotal
unless $sth 0 19 19
22 19 my @row = $sth->fetchrow_array;
23 19 ▶ return unless @row;
Branch: 1 branch
BranchTrueFalseTotal
unless @row 3 16 19
24 16 $count++;
25 16 return \@row;
26 38 }
27
28 1 ▶ method all () {
Subroutine all: called CC=5 SCAR=16.5
Pod documented
29 1 ▶ return [] unless $sth; # prepare failed under RaiseError => 0
Branch: 1 branch
BranchTrueFalseTotal
unless $sth 0 1 1
30 # Same hashes as fetchall_arrayref({}), built from the driver's C fetchall
31 # (see DBIx::Fast::SQL::_shape_rows).
32 1 ▶ my $names = $sth->FETCH($sth->FETCH('FetchHashKeyName') || 'NAME');
Condition50%1/2
$sth->FETCH('FetchHashKeyName') || 'NAME'
l!l
10
MC/DC0%0/1
$sth->FETCH('FetchHashKeyName') || 'NAME'
$sth->FETCH('FetchHashKeyName')
Truth table50%1/2
A
A= $sth->FETCH('FetchHashKeyName')
Aresult
11
00
33 my $rows = $names
34 1 ▶ ? [ map { my %h; @h{@$names} = @$_; \%h } @{ $sth->fetchall_arrayref // [] } ]
Branch: 1 branch
BranchTrueFalseTotal
$names ? : 1 0 1
Condition50%1/2
$sth->fetchall_arrayref // []
l!l
10
MC/DC0%0/1
$sth->fetchall_arrayref // []
$sth->fetchall_arrayref
Truth table50%1/2
A
A= $sth->fetchall_arrayref
Aresult
11
00
35 : $sth->fetchall_arrayref({});
36 1 $count += scalar @$rows;
37 1 return $rows;
38 38 }
39
40 1 ▶ method flat () {
Subroutine flat: called CC=2 SCAR=7.0
Pod documented
41 1 ▶ return [] unless $sth; # prepare failed under RaiseError => 0
Branch: 1 branch
BranchTrueFalseTotal
unless $sth 0 1 1
42 # fetchall_arrayref([0]) loops in DBI's C path - much faster than a
43 # per-row Perl fetch on large result sets.
44 1 my $col = $sth->fetchall_arrayref([0]);
45 1 $count += scalar @$col;
46 1 return [ map { $_->[0] } @$col ];
47 38 }
48
49 23 ▶ method finish () {
Subroutine finish: called CC=3 SCAR=11.0
Pod documented
50 # eval: an iterator can outlive its connection (disconnect, reconnect);
51 # asking a statement of a closed handle for Active is an error then.
52 23 ▶ $sth->finish if $sth && eval { $sth->FETCH('Active') };
Branch: 1 branch
BranchTrueFalseTotal
if $sth and eval { do { $sth->FETCH("Active") } } 9 14 23
Condition100%3/3
$sth and eval { do { $sth->FETCH("Active") } }
!ll&&!rl&&r
1139
MC/DC100%2/2
$sth and eval { do { $sth->FETCH("Active") } }
$sth eval { do { $sth->FETCH("Active") } }
Truth table100%3/3
A and B
A= $sthB= eval { do { $sth->FETCH("Active") } }
ABresult
0X0
100
111
53 38 }
54
55 16 ▶ method DESTROY () {
Subroutine DESTROY: called CC=1 SCAR=0.0
56 16 $self->finish;
57 38 }
58  
59 }
60  
61 38 1;
62  
63 __END__
« Fast/Output.pm ↑ Summary Fast/Cache/Redis.pm »