| 1 | 28 | ▶ | use v5.36; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | package DBIx::Squirrel::st; | ||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||
| 5 | 28 | ▶ | use DBI qw(); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 6 | 28 | ▶ | use List::Util qw(pairs); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 7 | 28 | ▶ | use Ref::Util qw(is_plain_arrayref); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||
| 9 | 28 | ▶ | use DBIx::Squirrel::Errors qw(at_caller croakf); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 10 | 28 | ▶ | use DBIx::Squirrel::Iterator qw(); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 11 | 28 | ▶ | use DBIx::Squirrel::Placeholders qw( | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 12 | is_numbered key_of place_values values_taken | ||||||||||||||||||||||||||||||||||||||||||
| 13 | 28 | ); | |||||||||||||||||||||||||||||||||||||||||
| 14 | 28 | ▶ | use DBIx::Squirrel::Results qw(); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 15 | 28 | ▶ | use Ekorn::Pipeline::Pipes qw(); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 16 | 28 | ▶ | use DBIx::Squirrel::Util qw(unwrap_values); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||
| 18 | 28 | ▶ | use namespace::clean; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||
| 20 | 28 | our @ISA = ('DBI::st', 'Ekorn::Pipeline::Pipes'); | |||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||
| 22 | # Croak at the line that called DBIx::Squirrel. | ||||||||||||||||||||||||||||||||||||||||||
| 23 | 28 | our @CARP_NOT = @DBIx::Squirrel::Errors::INTERNAL; | |||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||
| 25 | # Bind values to the statement's placeholders, without executing it, and | ||||||||||||||||||||||||||||||||||||||||||
| 26 | # return the handle, or nothing if the DBI couldn't bind one. Numbered | ||||||||||||||||||||||||||||||||||||||||||
| 27 | # placeholders take values in order, the first to every use of 1, and so | ||||||||||||||||||||||||||||||||||||||||||
| 28 | # on; named ones take a hash reference or a list of names and values. An | ||||||||||||||||||||||||||||||||||||||||||
| 29 | # array reference stands for the values in it. | ||||||||||||||||||||||||||||||||||||||||||
| 30 | 69 | ▶ | sub bind ($self, @args) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
bind: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 31 | 69 | return _bind($self, _binds($self), _unwrap($self, @args)); | |||||||||||||||||||||||||||||||||||||||||
| 32 | } | ||||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||
| 34 | # Bind values, as bind does, given as a list, and the statement's map of | ||||||||||||||||||||||||||||||||||||||||||
| 35 | # placeholders to positions, if it has one. Each value is bound to its | ||||||||||||||||||||||||||||||||||||||||||
| 36 | # positions directly, with the DBI's bind_param. | ||||||||||||||||||||||||||||||||||||||||||
| 37 | 69 | ▶ | sub _bind ($self, $binds, @args) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_bind: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 38 | 69 | my @placed; | |||||||||||||||||||||||||||||||||||||||||
| 39 | 69 | ▶ | if ($binds) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 40 | 64 | my $given = DBIx::Squirrel::Placeholders::_values_for($binds, \@args); ## no critic (Subroutines::ProtectPrivateSubs) | |||||||||||||||||||||||||||||||||||||||||
| 41 | 61 | my $state = $self->{private_ekorn}; | |||||||||||||||||||||||||||||||||||||||||
| 42 | 61 | @placed = @{ DBIx::Squirrel::Placeholders::_place_values($state, $given) }; ## no critic (Subroutines::ProtectPrivateSubs) | |||||||||||||||||||||||||||||||||||||||||
| 43 | } | ||||||||||||||||||||||||||||||||||||||||||
| 44 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 45 | 5 | @placed = map { ($_ => $args[$_ - 1]) } 1 .. @args; | |||||||||||||||||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||||||||||||||||
| 47 | 66 | ▶ | return at_caller { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||
| 48 | 66 | for my $pair (pairs @placed) { | |||||||||||||||||||||||||||||||||||||||||
| 49 | 111 | ▶ | $self->SUPER::bind_param(@$pair) or return; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||||||||||||||||
| 51 | 65 | ▶ | $self->{private_ekorn}{AllBound} = 1 if $binds; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 52 | 65 | $self; | |||||||||||||||||||||||||||||||||||||||||
| 53 | 66 | }; | |||||||||||||||||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||||||||
| 56 | # Bind a value to a placeholder, as the DBI's bind_param does, given its | ||||||||||||||||||||||||||||||||||||||||||
| 57 | # number or its name, with or without the sigil, and bind it to every use | ||||||||||||||||||||||||||||||||||||||||||
| 58 | # of that placeholder in the statement; for a list placeholder, bind each | ||||||||||||||||||||||||||||||||||||||||||
| 59 | # value in the list to a position of its own. Return what the DBI returns. | ||||||||||||||||||||||||||||||||||||||||||
| 60 | 17 | ▶ | sub bind_param ($self, $param, $value, @attrs) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
bind_param: called CC=9 SCAR=22.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 61 | my $binds = _binds($self) | ||||||||||||||||||||||||||||||||||||||||||
| 62 | 17 | ▶ | or return at_caller { $self->SUPER::bind_param($param, $value, @attrs) }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 63 | 15 | my $key = key_of($param); | |||||||||||||||||||||||||||||||||||||||||
| 64 | 15 | ▶ | unless ($binds->{$key}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||||||
| 66 | # A position, for a statement with named placeholders. | ||||||||||||||||||||||||||||||||||||||||||
| 67 | 6 | ▶ | if ($param =~ m( \A \d+ \z )xa && !is_numbered($binds)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$param =~ / \A \d+ \z /ax and not is_numbered($binds)
MC/DC100%2/2
$param =~ / \A \d+ \z /ax and not is_numbered($binds)
$param =~ / \A \d+ \z /ax
not is_numbered($binds)
Truth table100%3/3
A and not(B)
A= $param =~ / \A \d+ \z /axB= not is_numbered($binds)
| |||||||||||||||||||||||||||||||||||||||||||
| 68 | 3 | ▶ | my $rv = at_caller { $self->SUPER::bind_param($param, $value, @attrs) }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 69 | 3 | ▶ | $self->{private_ekorn}{Bound}{$param} = 1 if $rv; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 70 | 3 | return $rv; | |||||||||||||||||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||||||||||||||||
| 72 | 3 | croakf 'Expected a placeholder of the statement (%s)', $param; | |||||||||||||||||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||||||||||||||||
| 74 | 9 | my @placed = pairs place_values($self->{private_ekorn}, $key => $value); | |||||||||||||||||||||||||||||||||||||||||
| 75 | 8 | my $rv; | |||||||||||||||||||||||||||||||||||||||||
| 76 | 8 | for my $pair (@placed) { | |||||||||||||||||||||||||||||||||||||||||
| 77 | 14 | ▶ | $rv = at_caller { $self->SUPER::bind_param(@$pair, @attrs) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 78 | 14 | ▶ | or return $rv; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 79 | } | ||||||||||||||||||||||||||||||||||||||||||
| 80 | 8 | $self->{private_ekorn}{Bound}{$_->[0]} = 1 for @placed; | |||||||||||||||||||||||||||||||||||||||||
| 81 | 8 | return $rv; | |||||||||||||||||||||||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||||||||||
| 84 | # Execute the statement, as the DBI's execute does, with any values given | ||||||||||||||||||||||||||||||||||||||||||
| 85 | # bound as bind binds them. Values for numbered or named placeholders go | ||||||||||||||||||||||||||||||||||||||||||
| 86 | # to the DBI's execute in the order of their positions, which binds them | ||||||||||||||||||||||||||||||||||||||||||
| 87 | # as bind_param would, in one call. With the ekorn_finish_active | ||||||||||||||||||||||||||||||||||||||||||
| 88 | # attribute, a statement still active from an earlier execute is finished | ||||||||||||||||||||||||||||||||||||||||||
| 89 | # first. | ||||||||||||||||||||||||||||||||||||||||||
| 90 | 1918 | ▶ | sub execute ($self, @args) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
execute: called CC=10 SCAR=23.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 91 | 1918 | my $state = $self->{private_ekorn}; | |||||||||||||||||||||||||||||||||||||||||
| 92 | $self->finish | ||||||||||||||||||||||||||||||||||||||||||
| 93 | 1918 | ▶ | if $state && $state->{Options}{ekorn_finish_active} && $self->{Active}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
$state and $state->{"Options"}{"ekorn_finish_active"} and $self->{"Active"}
$state and $state->{"Options"}{"ekorn_finish_active"}
MC/DC66%2/3
$state and $state->{"Options"}{"ekorn_finish_active"} and $self->{"Active"}
$state
$state->{"Options"}{"ekorn_finish_active"}
$self->{"Active"}
Truth table75%3/4
A and B and C
A= $stateB= $state->{"Options"}{"ekorn_finish_active"}C= $self->{"Active"}
| |||||||||||||||||||||||||||||||||||||||||||
| 94 | # Only values in an array reference given alone need unwrapping, and | ||||||||||||||||||||||||||||||||||||||||||
| 95 | # most aren't: the call, copying them in and out, is left out for | ||||||||||||||||||||||||||||||||||||||||||
| 96 | # them (roadmap 2026-0028). | ||||||||||||||||||||||||||||||||||||||||||
| 97 | 1918 | ▶ | @args = _unwrap($self, @args) if @args == 1 && is_plain_arrayref($args[0]); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
@args == 1 and Ref::Util::XS::is_plain_arrayref($args[0])
MC/DC100%2/2
@args == 1 and Ref::Util::XS::is_plain_arrayref($args[0])
@args == 1
Ref::Util::XS::is_plain_arrayref($args[0])
Truth table100%3/3
A and B
A= @args == 1B= Ref::Util::XS::is_plain_arrayref($args[0])
| |||||||||||||||||||||||||||||||||||||||||||
| 98 | 1918 | ▶ | my $binds = $state && $state->{Binds}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$state && $state->{'Binds'}
MC/DC50%1/2
$state && $state->{'Binds'}
$state
$state->{'Binds'}
Truth table66%2/3
A && B
A= $stateB= $state->{'Binds'}
| |||||||||||||||||||||||||||||||||||||||||||
| 99 | 1918 | ▶ | if ($binds) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 100 | 132 | ▶ | _check_bound($self) unless @args; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 101 | 127 | ▶ | @args = _in_order($state, \@args) if @args; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 102 | 118 | $state->{AllBound} = 1; | |||||||||||||||||||||||||||||||||||||||||
| 103 | } | ||||||||||||||||||||||||||||||||||||||||||
| 104 | 1904 | ▶ | return at_caller { $self->SUPER::execute(@args) }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 105 | } | ||||||||||||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||||||||||||
| 107 | # Return an iterator over the statement's results, executed with the bind | ||||||||||||||||||||||||||||||||||||||||||
| 108 | # values given, and run through the stages given after them; or, if the | ||||||||||||||||||||||||||||||||||||||||||
| 109 | # last stage is a sink, the sink's result. | ||||||||||||||||||||||||||||||||||||||||||
| 110 | 421 | ▶ | sub iterate ($self, @args) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
iterate: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 111 | 421 | return DBIx::Squirrel::Iterator->new($self, @args)->_or_sink; ## no critic (Subroutines::ProtectPrivateSubs) | |||||||||||||||||||||||||||||||||||||||||
| 112 | } | ||||||||||||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||||||||||||
| 114 | # Return a result set over the statement's results: an iterator handing | ||||||||||||||||||||||||||||||||||||||||||
| 115 | # out rows as objects; or, if the last stage is a sink, the sink's result. | ||||||||||||||||||||||||||||||||||||||||||
| 116 | 44 | ▶ | sub results ($self, @args) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
results: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 117 | 44 | return DBIx::Squirrel::Results->new($self, @args)->_or_sink; ## no critic (Subroutines::ProtectPrivateSubs) | |||||||||||||||||||||||||||||||||||||||||
| 118 | } | ||||||||||||||||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||||||||||||||||
| 120 | # Return the values given, or those in an array reference given alone, | ||||||||||||||||||||||||||||||||||||||||||
| 121 | # as unwrap_values does. Values not given in an array reference alone, | ||||||||||||||||||||||||||||||||||||||||||
| 122 | # as most aren't, are returned at once, without reading the driver's name | ||||||||||||||||||||||||||||||||||||||||||
| 123 | # through the handles' attributes. | ||||||||||||||||||||||||||||||||||||||||||
| 124 | 194 | ▶ | sub _unwrap ($self, @args) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_unwrap: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||
| 125 | return @args | ||||||||||||||||||||||||||||||||||||||||||
| 126 | 194 | ▶ | unless @args == 1 && is_plain_arrayref($args[0]); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
@args == 1 and Ref::Util::XS::is_plain_arrayref($args[0])
MC/DC100%2/2
@args == 1 and Ref::Util::XS::is_plain_arrayref($args[0])
@args == 1
Ref::Util::XS::is_plain_arrayref($args[0])
Truth table100%3/3
A and B
A= @args == 1B= Ref::Util::XS::is_plain_arrayref($args[0])
| |||||||||||||||||||||||||||||||||||||||||||
| 127 | 30 | my $state = $self->{private_ekorn}; | |||||||||||||||||||||||||||||||||||||||||
| 128 | return unwrap_values( | ||||||||||||||||||||||||||||||||||||||||||
| 129 | $self->{Database}{Driver}{Name}, | ||||||||||||||||||||||||||||||||||||||||||
| 130 | 19 | ▶ | sub { _values_taken($self) }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 131 | 30 | ▶ | $state && $state->{Lists}, @args, | ||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$state && $state->{'Lists'}
MC/DC50%1/2
$state && $state->{'Lists'}
$state
$state->{'Lists'}
Truth table66%2/3
A && B
A= $stateB= $state->{'Lists'}
| |||||||||||||||||||||||||||||||||||||||||||
| 132 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 133 | } | ||||||||||||||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||||||||||||
| 135 | # Return how many values the statement takes in order: one for each | ||||||||||||||||||||||||||||||||||||||||||
| 136 | # placeholder the DBI sees, or each number, or none if they're named. | ||||||||||||||||||||||||||||||||||||||||||
| 137 | 19 | ▶ | sub _values_taken ($self) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_values_taken: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 138 | my $binds = _binds($self) | ||||||||||||||||||||||||||||||||||||||||||
| 139 | 19 | ▶ | or return $self->{NUM_OF_PARAMS}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 140 | 17 | return values_taken($binds); | |||||||||||||||||||||||||||||||||||||||||
| 141 | } | ||||||||||||||||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||||||||||||||||
| 143 | # Return the statement's map of each placeholder's number or name to its | ||||||||||||||||||||||||||||||||||||||||||
| 144 | # positions, or nothing if the statement went to the DBI as written. | ||||||||||||||||||||||||||||||||||||||||||
| 145 | 105 | ▶ | sub _binds ($self) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_binds: called CC=2 SCAR=7.1
| |||||||||||||||||||||||||||||||||||||||||||
| 146 | 105 | my $state = $self->{private_ekorn}; | |||||||||||||||||||||||||||||||||||||||||
| 147 | 105 | ▶ | return $state && $state->{Binds}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$state && $state->{'Binds'}
MC/DC50%1/2
$state && $state->{'Binds'}
$state
$state->{'Binds'}
Truth table66%2/3
A && B
A= $stateB= $state->{'Binds'}
| |||||||||||||||||||||||||||||||||||||||||||
| 148 | } | ||||||||||||||||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||||||||||||||||
| 150 | # Croak unless a value has been bound to every use of each of the | ||||||||||||||||||||||||||||||||||||||||||
| 151 | # placeholders of a statement with numbered or named ones: given to | ||||||||||||||||||||||||||||||||||||||||||
| 152 | # execute or bind, which bind them all, or to bind_param. Unbound, the | ||||||||||||||||||||||||||||||||||||||||||
| 153 | # driver would read them as NULL, or fail. | ||||||||||||||||||||||||||||||||||||||||||
| 154 | 50 | ▶ | sub _check_bound ($self) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_check_bound: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||
| 155 | 50 | my $state = $self->{private_ekorn}; | |||||||||||||||||||||||||||||||||||||||||
| 156 | 50 | ▶ | return if $state->{AllBound}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 157 | 11 | my $binds = $state->{Binds}; | |||||||||||||||||||||||||||||||||||||||||
| 158 | 11 | ▶ | my $bound = $state->{Bound} // {}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$state->{"Bound"} // {}
MC/DC100%1/1
$state->{"Bound"} // {}
$state->{"Bound"}
Truth table100%2/2
A
A= $state->{"Bound"}
| |||||||||||||||||||||||||||||||||||||||||||
| 159 | my @missing = sort grep { | ||||||||||||||||||||||||||||||||||||||||||
| 160 | 11 | grep { !$bound->{$_} } | |||||||||||||||||||||||||||||||||||||||||
| 161 | 17 | @{ $binds->{$_} } | |||||||||||||||||||||||||||||||||||||||||
| 162 | } keys %$binds; | ||||||||||||||||||||||||||||||||||||||||||
| 163 | 11 | ▶ | croakf 'Expected a value for each placeholder (none for %s)', | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 164 | join(', ', @missing) | ||||||||||||||||||||||||||||||||||||||||||
| 165 | if @missing; | ||||||||||||||||||||||||||||||||||||||||||
| 166 | 3 | return; | |||||||||||||||||||||||||||||||||||||||||
| 167 | } | ||||||||||||||||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||||||||||||||||
| 169 | # Return the values for a statement's placeholders, as values_for finds | ||||||||||||||||||||||||||||||||||||||||||
| 170 | # them, in the order of their positions, each as often as it's used, and | ||||||||||||||||||||||||||||||||||||||||||
| 171 | # each value in a list at a position of its own, given what the statement | ||||||||||||||||||||||||||||||||||||||||||
| 172 | # handle keeps about the statement. | ||||||||||||||||||||||||||||||||||||||||||
| 173 | # | ||||||||||||||||||||||||||||||||||||||||||
| 174 | # A statement without list placeholders keeps their order, so its values | ||||||||||||||||||||||||||||||||||||||||||
| 175 | # are put in it with a slice (roadmap 2026-0028). | ||||||||||||||||||||||||||||||||||||||||||
| 176 | 86 | ▶ | sub _in_order ($state, $args) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_in_order: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||
| 177 | 86 | my $given = DBIx::Squirrel::Placeholders::_values_for($state->{Binds}, $args); ## no critic (Subroutines::ProtectPrivateSubs) | |||||||||||||||||||||||||||||||||||||||||
| 178 | 78 | ▶ | if (my $order = $state->{Order}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 179 | 56 | return @$given{@$order}; | |||||||||||||||||||||||||||||||||||||||||
| 180 | } | ||||||||||||||||||||||||||||||||||||||||||
| 181 | # A list's values go to positions of their own, each pair a position | ||||||||||||||||||||||||||||||||||||||||||
| 182 | # and its value, put in order without a hash of them. | ||||||||||||||||||||||||||||||||||||||||||
| 183 | 22 | my $placed = DBIx::Squirrel::Placeholders::_place_values($state, $given); ## no critic (Subroutines::ProtectPrivateSubs) | |||||||||||||||||||||||||||||||||||||||||
| 184 | 21 | my @in_order; | |||||||||||||||||||||||||||||||||||||||||
| 185 | 21 | ▶ | for (my $i = 0; $i < @$placed; $i += 2) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 186 | 39 | $in_order[$placed->[$i] - 1] = $placed->[$i + 1]; | |||||||||||||||||||||||||||||||||||||||||
| 187 | } | ||||||||||||||||||||||||||||||||||||||||||
| 188 | 21 | return @in_order; | |||||||||||||||||||||||||||||||||||||||||
| 189 | } | ||||||||||||||||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||||||||||||||||
| 191 | 28 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 192 | __END__ | ||||||||||||||||||||||||||||||||||||||||||