| 1 | package WebDyne::Cloudflare::Hyperdrive::Statement; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use 5.020; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 1 | ▶ | use Future::AsyncAwait; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 1 | ▶ | use JSON::PP (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 1 | ▶ | use Scalar::Util qw(blessed); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 1 | ▶ | use WebDyne::Cloudflare::Hyperdrive::Codec; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 1 | ▶ | use WebDyne::Cloudflare::Hyperdrive::Blob; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 1 | our $VERSION='0.001'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 15 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 15 | my ($class, %opt)=@_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 15 | return bless({ database => $opt{'database'}, sql => $opt{'sql'}, bindings => {}, hints => {}, position => 0 }, $class); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 73 | ▶ | sub available { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
available: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 73 | my ($self)=@_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 73 | $self->{'database'}->available(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 70 | ▶ | die "Hyperdrive statement execution is in progress\n" if $self->{'busy'}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 11 | ▶ | sub parameter { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
parameter: called CC=14 SCAR=31.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 11 | my ($value_ref, $type)=@_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 11 | ▶ | if (defined($type)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 6 | ▶ | die "Unsupported Hyperdrive parameter type\n" if ref($type)||($type!~/\A(?:text|boolean|bytea)\z/); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
ref $type or not $type =~ /\A(?:text|boolean|bytea)\z/u
MC/DC50%1/2
ref $type or not $type =~ /\A(?:text|boolean|bytea)\z/u
ref $type
not $type =~ /\A(?:text|boolean|bytea)\z/u
Truth table66%2/3
A or not(B)
A= ref $typeB= not $type =~ /\A(?:text|boolean|bytea)\z/u
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 5 | ▶ | if (defined($value_ref)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 5 | ▶ | if ($type eq 'bytea') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 3 | ▶ | $value_ref=WebDyne::Cloudflare::Hyperdrive::Blob->new($value_ref) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
builtin::blessed($value_ref) and $value_ref->isa("WebDyne::Cloudflare::Hyperdrive::Blob")
MC/DC0%0/2
builtin::blessed($value_ref) and $value_ref->isa("WebDyne::Cloudflare::Hyperdrive::Blob")
builtin::blessed($value_ref)
$value_ref->isa("WebDyne::Cloudflare::Hyperdrive::Blob")
Truth table33%1/3
A and B
A= builtin::blessed($value_ref)B= $value_ref->isa("WebDyne::Cloudflare::Hyperdrive::Blob")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | unless blessed($value_ref)&&$value_ref->isa('WebDyne::Cloudflare::Hyperdrive::Blob'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | elsif ($type eq 'boolean') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 2 | ▶ | die "Hyperdrive boolean requires 0, 1 or a JSON boolean\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
JSON::PP::is_bool($value_ref) or not ref $value_ref and $value_ref =~ /\A[01]\z/u
not ref $value_ref and $value_ref =~ /\A[01]\z/u
MC/DC0%0/3
JSON::PP::is_bool($value_ref) or not ref $value_ref and $value_ref =~ /\A[01]\z/u
JSON::PP::is_bool($value_ref)
not ref $value_ref
$value_ref =~ /\A[01]\z/u
Truth table25%1/4
A or not(B) and C
A= JSON::PP::is_bool($value_ref)B= not ref $value_refC= $value_ref =~ /\A[01]\z/u
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | unless JSON::PP::is_bool($value_ref)||(!ref($value_ref)&&($value_ref=~/\A[01]\z/)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 2 | ▶ | $value_ref=$value_ref ? JSON::PP::true() : JSON::PP::false(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 0 | ▶ | else { die "Hyperdrive text requires a scalar\n" if ref($value_ref) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 9 | return WebDyne::Cloudflare::Hyperdrive::Codec::parameters($value_ref)->[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 9 | ▶ | sub bind_param { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
bind_param: called CC=8 SCAR=21.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 9 | my ($self, $position, $value_ref, $type)=@_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 9 | $self->available(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 9 | ▶ | die "Hyperdrive bind_param requires position, value and optional type\n" unless (@_==3)||(@_==4); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
@_ == 3 or @_ == 4
MC/DC0%0/2
@_ == 3 or @_ == 4
@_ == 3
@_ == 4
Truth table66%2/3
A or B
A= @_ == 3B= @_ == 4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 9 | ▶ | die "Hyperdrive parameter positions are integers from 1 to 65535\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%6/9
defined $position and not ref $position and $position =~ /\A[1-9][0-9]*\z/u and $position <= 65535
defined $position and not ref $position and $position =~ /\A[1-9][0-9]*\z/u
defined $position and not ref $position
MC/DC50%2/4
defined $position and not ref $position and $position =~ /\A[1-9][0-9]*\z/u and $position <= 65535
defined $position
not ref $position
$position =~ /\A[1-9][0-9]*\z/u
$position <= 65535
Truth table60%3/5
A and not(B) and C and D
A= defined $positionB= not ref $positionC= $position =~ /\A[1-9][0-9]*\z/uD= $position <= 65535
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | unless defined($position)&&!ref($position)&&($position=~/\A[1-9][0-9]*\z/)&&($position<=65535); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 4 | ▶ | my $hint=defined($type) ? $type : $self->{'hints'}{$position}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 4 | $self->{'bindings'}{$position}=parameter($value_ref, $hint); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 3 | $self->{'hints'}{$position}=$hint; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 3 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 24 | ▶ | sub execute { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
execute: called CC=6 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 24 | my ($self, @bind)=@_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 24 | $self->available(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 23 | delete($self->{'result'}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 23 | $self->{'position'}=0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 23 | ▶ | if (@bind) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 4 | ▶ | die "Hyperdrive accepts at most 65535 parameters\n" if @bind>65535; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 4 | my %bindings; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 4 | foreach my $index (0..$#bind) { $bindings{$index+1}=parameter($bind[$index], $self->{'hints'}{$index+1}) } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 3 | $self->{'bindings'}=\%bindings; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 22 | my @positions=sort { $a<=>$b } keys(%{$self->{'bindings'}}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 22 | ▶ | die "Hyperdrive bound parameter positions must be contiguous\n" if @positions&&($positions[-1]!=@positions); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
@positions and $positions[-1] != @positions
MC/DC100%2/2
@positions and $positions[-1] != @positions
@positions
$positions[-1] != @positions
Truth table100%3/3
A and B
A= @positionsB= $positions[-1] != @positions
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 21 | my $params_ar=[map { $self->{'bindings'}{$_} } @positions]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 21 | $self->{'busy'}=1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 21 | my $future_or=$self->run($params_ar); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 21 | ▶ | $future_or->on_ready(sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 21 | $self->{'busy'}=0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 21 | ▶ | delete($self->{'result'}) unless $future_or->is_done(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 21 | }); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 21 | return $future_or; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 21 | ▶ | async sub run { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
run: called CC=3 SCAR=11.6
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 21 | my ($self, $params_ar)=@_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 21 | my $result_hr=await $self->{'database'}->request('query', sql => $self->{'sql'}, params => $params_ar); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 19 | ▶ | die "Hyperdrive query omitted row metadata\n" unless (ref($result_hr->{'rows'}) eq 'ARRAY')&&(ref($result_hr->{'columns'}) eq 'ARRAY'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
ref $result_hr->{"rows"} eq "ARRAY" and ref $result_hr->{"columns"} eq "ARRAY"
MC/DC0%0/2
ref $result_hr->{"rows"} eq "ARRAY" and ref $result_hr->{"columns"} eq "ARRAY"
ref $result_hr->{"rows"} eq "ARRAY"
ref $result_hr->{"columns"} eq "ARRAY"
Truth table33%1/3
A and B
A= ref $result_hr->{"rows"} eq "ARRAY"B= ref $result_hr->{"columns"} eq "ARRAY"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 19 | $self->{'result'}=$result_hr; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 19 | return count_value($result_hr->{'count'}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 1 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 0 | ▶ | sub rows { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
rows: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 0 | my ($self)=@_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 0 | ▶ | die "Hyperdrive rows takes no arguments\n" unless @_==1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 0 | $self->available(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 0 | ▶ | return count_value($self->{'result'} ? $self->{'result'}{'count'} : undef); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 19 | ▶ | sub count_value { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
count_value: called CC=5 SCAR=16.7
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 19 | my ($count)=@_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 19 | ▶ | return -1 unless defined($count); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 18 | ▶ | die "Invalid Hyperdrive affected row count\n" if ref($count)||($count!~/\A[0-9]+\z/); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
ref $count or not $count =~ /\A[0-9]+\z/u
MC/DC0%0/2
ref $count or not $count =~ /\A[0-9]+\z/u
ref $count
not $count =~ /\A[0-9]+\z/u
Truth table33%1/3
A or not(B)
A= ref $countB= not $count =~ /\A[0-9]+\z/u
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 18 | ▶ | return $count ? 0+$count : '0E0'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 24 | ▶ | sub fetchrow_arrayref { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
fetchrow_arrayref: called CC=4 SCAR=13.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 24 | my ($self)=@_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 24 | ▶ | die "Hyperdrive fetchrow_arrayref takes no arguments\n" unless @_==1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 24 | $self->available(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 20 | ▶ | return undef unless $self->{'result'}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 16 | my $row_ar=$self->{'result'}{'rows'}[$self->{'position'}]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 16 | ▶ | return undef unless defined($row_ar); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 9 | $self->{'position'}++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 9 | return [@{$row_ar}]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 10 | ▶ | sub fetchrow_hashref { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
fetchrow_hashref: called CC=4 SCAR=13.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 10 | my ($self)=@_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 10 | ▶ | die "Hyperdrive fetchrow_hashref takes no arguments\n" unless @_==1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 10 | my $row_ar=$self->fetchrow_arrayref(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 10 | ▶ | return undef unless defined($row_ar); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 6 | my %row; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 6 | my $columns_ar=$self->{'result'}{'columns'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 6 | foreach my $index (0..$#{$columns_ar}) { $row{$columns_ar->[$index]{'name'}}=$row_ar->[$index] } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 6 | return \%row; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 6 | ▶ | sub fetchall_arrayref { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
fetchall_arrayref: called CC=7 SCAR=19.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 6 | my ($self, $slice_hr)=@_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 6 | $self->available(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | die "Hyperdrive fetchall_arrayref accepts only undef or an empty hash\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 6 | ▶ | if (@_>2)||(defined($slice_hr)&&((ref($slice_hr) ne 'HASH')||keys(%{$slice_hr}))); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition77%7/9
@_ > 2 or defined $slice_hr and ref $slice_hr ne "HASH" || keys %{$slice_hr;}
defined $slice_hr and ref $slice_hr ne "HASH" || keys %{$slice_hr;}
ref $slice_hr ne "HASH" or keys %{$slice_hr;}
MC/DC50%2/4
@_ > 2 or defined $slice_hr and ref $slice_hr ne "HASH" || keys %{$slice_hr;}
@_ > 2
defined $slice_hr
ref $slice_hr ne "HASH"
keys %{$slice_hr;}
Truth table60%3/5
A or B and C or D
A= @_ > 2B= defined $slice_hrC= ref $slice_hr ne "HASH"D= keys %{$slice_hr;}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 5 | my @rows; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 5 | ▶ | while (defined(my $row_ref=defined($slice_hr) ? $self->fetchrow_hashref() : $self->fetchrow_arrayref())) { push(@rows, $row_ref) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 5 | return \@rows; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 2 | ▶ | sub columns { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
columns: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 2 | my ($self)=@_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 2 | ▶ | die "Hyperdrive columns takes no arguments\n" unless @_==1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 2 | $self->available(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 2 | ▶ | return [] unless $self->{'result'}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 1 | return [map { { %{$_} } } @{$self->{'result'}{'columns'}}]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 1 | ▶ | sub command { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
command: called CC=3 SCAR=11.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 1 | my ($self)=@_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 1 | ▶ | die "Hyperdrive command takes no arguments\n" unless @_==1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 1 | $self->available(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 1 | ▶ | return $self->{'result'} ? $self->{'result'}{'command'} : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 3 | ▶ | sub insert_id { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
insert_id: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 3 | my ($self)=@_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 3 | ▶ | die "Hyperdrive insert_id takes no arguments\n" unless @_==1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 3 | $self->available(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 3 | ▶ | return $self->{'result'} ? $self->{'result'}{'insert_id'} : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 1 | ▶ | sub affected_rows { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
affected_rows: called CC=3 SCAR=11.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 1 | my ($self)=@_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 1 | ▶ | die "Hyperdrive affected_rows takes no arguments\n" unless @_==1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 1 | $self->available(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 1 | ▶ | return $self->{'result'} ? $self->{'result'}{'affected_rows'} : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 1 | ▶ | sub warning_count { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
warning_count: called CC=3 SCAR=11.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 1 | my ($self)=@_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 1 | ▶ | die "Hyperdrive warning_count takes no arguments\n" unless @_==1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 1 | $self->available(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 1 | ▶ | return $self->{'result'} ? $self->{'result'}{'warning_count'} : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 2 | ▶ | sub finish { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
finish: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 2 | my ($self)=@_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 2 | ▶ | die "Hyperdrive finish takes no arguments\n" unless @_==1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 2 | $self->available(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 2 | delete($self->{'result'}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 2 | $self->{'position'}=0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 2 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||