| 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
| |||||||||||||||||||||||||||||
| 15 | 8 | my $row = $sth->fetchrow_hashref; | |||||||||||||||||||||||||||
| 16 | 8 | ▶ | $count++ if $row; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 22 | 19 | my @row = $sth->fetchrow_array; | |||||||||||||||||||||||||||
| 23 | 19 | ▶ | return unless @row; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 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'
MC/DC0%0/1
$sth->FETCH('FetchHashKeyName') || 'NAME'
$sth->FETCH('FetchHashKeyName')
Truth table50%1/2
A
A= $sth->FETCH('FetchHashKeyName')
| |||||||||||||||||||||||||||||
| 33 | my $rows = $names | ||||||||||||||||||||||||||||
| 34 | 1 | ▶ | ? [ map { my %h; @h{@$names} = @$_; \%h } @{ $sth->fetchall_arrayref // [] } ] | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
$sth->fetchall_arrayref // []
MC/DC0%0/1
$sth->fetchall_arrayref // []
$sth->fetchall_arrayref
Truth table50%1/2
A
A= $sth->fetchall_arrayref
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 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
Condition100%3/3
$sth and eval {
do {
$sth->FETCH("Active")
}
}
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")
}
}
| |||||||||||||||||||||||||||||
| 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__ | ||||||||||||||||||||||||||||