« lib/WebDyne/Cloudflare/DurableObject/Bytes.pm
↑ Summary
blib/lib/WebDyne/Cloudflare/Hyperdrive/Blob.pm »
| 1 | package WebDyne::Cloudflare::D1::Statement; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | 5 | ▶ | use 5.020; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | 5 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | 5 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 6 | 5 | ▶ | use Future::AsyncAwait; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 7 | 5 | ▶ | use JSON::PP (); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 8 | 5 | ▶ | use Scalar::Util qw(blessed refaddr); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||
| 10 | 5 | our $VERSION='0.001'; | |||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||
| 12 | 60 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 13 | 60 | my ($class, %opt)=@_; | |||||||||||||||||||||||||||||||||||||||||
| 14 | my $self=bless({ | ||||||||||||||||||||||||||||||||||||||||||
| 15 | database => $opt{'database'}, | ||||||||||||||||||||||||||||||||||||||||||
| 16 | sql => $opt{'sql'}, | ||||||||||||||||||||||||||||||||||||||||||
| 17 | 60 | ▶ | params => (defined($opt{'params'}) ? $opt{'params'} : []), | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 18 | }, $class); | ||||||||||||||||||||||||||||||||||||||||||
| 19 | 60 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 20 | } | ||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||
| 23 | 22 | ▶ | sub bind { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
bind: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 24 | 22 | my ($self, @param)=@_; | |||||||||||||||||||||||||||||||||||||||||
| 25 | return ref($self)->new( | ||||||||||||||||||||||||||||||||||||||||||
| 26 | database => $self->{'database'}, | ||||||||||||||||||||||||||||||||||||||||||
| 27 | 22 | sql => $self->{'sql'}, | |||||||||||||||||||||||||||||||||||||||||
| 28 | params => \@param, | ||||||||||||||||||||||||||||||||||||||||||
| 29 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 30 | } | ||||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||
| 33 | 32 | ▶ | sub batch_request { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
batch_request: called CC=8 SCAR=23.7
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 34 | 32 | my ($self, $database_or)=@_; | |||||||||||||||||||||||||||||||||||||||||
| 35 | 32 | my $owner_or=$self->{'database'}; | |||||||||||||||||||||||||||||||||||||||||
| 36 | 32 | ▶ | die "D1 batch statements must belong to the same database object\n" | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%3/6
builtin::blessed($owner_or) and $owner_or->isa("WebDyne::Cloudflare::D1") and builtin::refaddr($owner_or) == builtin::refaddr($database_or)
builtin::blessed($owner_or) and $owner_or->isa("WebDyne::Cloudflare::D1")
MC/DC33%1/3
builtin::blessed($owner_or) and $owner_or->isa("WebDyne::Cloudflare::D1") and builtin::refaddr($owner_or) == builtin::refaddr($database_or)
builtin::blessed($owner_or)
$owner_or->isa("WebDyne::Cloudflare::D1")
builtin::refaddr($owner_or) == builtin::refaddr($database_or)
Truth table50%2/4
A and B and C
A= builtin::blessed($owner_or)B= $owner_or->isa("WebDyne::Cloudflare::D1")C= builtin::refaddr($owner_or) == builtin::refaddr($database_or)
| |||||||||||||||||||||||||||||||||||||||||||
| 37 | unless (blessed($owner_or)&&$owner_or->isa('WebDyne::Cloudflare::D1') | ||||||||||||||||||||||||||||||||||||||||||
| 38 | &&(refaddr($owner_or)==refaddr($database_or))); | ||||||||||||||||||||||||||||||||||||||||||
| 39 | 22 | my $sql=$self->{'sql'}; | |||||||||||||||||||||||||||||||||||||||||
| 40 | 22 | ▶ | die "D1 batch statement requires a non-empty SQL string\n" | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
defined $sql and not ref $sql and length $sql
defined $sql and not ref $sql
MC/DC0%0/3
defined $sql and not ref $sql and length $sql
defined $sql
not ref $sql
length $sql
Truth table25%1/4
A and not(B) and C
A= defined $sqlB= not ref $sqlC= length $sql
| |||||||||||||||||||||||||||||||||||||||||||
| 41 | unless (defined($sql)&&!ref($sql)&&length($sql)); | ||||||||||||||||||||||||||||||||||||||||||
| 42 | die "D1 batch statement parameters must be an array reference\n" | ||||||||||||||||||||||||||||||||||||||||||
| 43 | 22 | ▶ | unless (ref($self->{'params'}) eq 'ARRAY'); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 44 | 22 | return {sql => $sql, params => [@{$self->{'params'}}]}; | |||||||||||||||||||||||||||||||||||||||||
| 45 | } | ||||||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||
| 48 | 13 | ▶ | async sub run { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
run: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 49 | 13 | my ($self)=@_; | |||||||||||||||||||||||||||||||||||||||||
| 50 | return await $self->{'database'}->execute( | ||||||||||||||||||||||||||||||||||||||||||
| 51 | operation => 'run', | ||||||||||||||||||||||||||||||||||||||||||
| 52 | sql => $self->{'sql'}, | ||||||||||||||||||||||||||||||||||||||||||
| 53 | 13 | params => $self->{'params'}, | |||||||||||||||||||||||||||||||||||||||||
| 54 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 55 | 5 | } | |||||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||
| 58 | 4 | ▶ | async sub all { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
all: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 59 | 4 | my ($self)=@_; | |||||||||||||||||||||||||||||||||||||||||
| 60 | 4 | return await $self->run(); | |||||||||||||||||||||||||||||||||||||||||
| 61 | 5 | } | |||||||||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||||||||
| 64 | 9 | ▶ | async sub first { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
first: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 65 | 9 | my ($self, $column)=@_; | |||||||||||||||||||||||||||||||||||||||||
| 66 | my %request=( | ||||||||||||||||||||||||||||||||||||||||||
| 67 | operation => 'first', | ||||||||||||||||||||||||||||||||||||||||||
| 68 | sql => $self->{'sql'}, | ||||||||||||||||||||||||||||||||||||||||||
| 69 | 9 | params => $self->{'params'}, | |||||||||||||||||||||||||||||||||||||||||
| 70 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 71 | 9 | ▶ | $request{'column'}=$column if defined($column); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 72 | 9 | return await $self->{'database'}->execute(%request); | |||||||||||||||||||||||||||||||||||||||||
| 73 | 5 | } | |||||||||||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||||||
| 76 | 4 | ▶ | async sub raw { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
raw: called CC=2 SCAR=7.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 77 | 4 | my ($self, %opt)=@_; | |||||||||||||||||||||||||||||||||||||||||
| 78 | return await $self->{'database'}->execute( | ||||||||||||||||||||||||||||||||||||||||||
| 79 | operation => 'raw', | ||||||||||||||||||||||||||||||||||||||||||
| 80 | sql => $self->{'sql'}, | ||||||||||||||||||||||||||||||||||||||||||
| 81 | params => $self->{'params'}, | ||||||||||||||||||||||||||||||||||||||||||
| 82 | 4 | ▶ | column_names => $opt{'column_names'} ? JSON::PP::true() : JSON::PP::false(), | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 83 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 84 | 5 | } | |||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||
| 86 | 5 | 1; | |||||||||||||||||||||||||||||||||||||||||