| 1 | 32 | ▶ | use v5.36; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | package DBIx::Squirrel::Context; | ||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | 32 | ▶ | use Exporter qw(import); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 32 | ▶ | use Ref::Util qw(is_plain_hashref); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 32 | ▶ | use DBIx::Squirrel::Errors qw(); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 32 | ▶ | use Ekorn::Pipeline qw(); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | 32 | ▶ | use Ekorn::Pipeline::Context qw(); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | 32 | ▶ | use namespace::clean -except => 'import'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | 32 | our $VERSION = 'v4.2.0'; | |||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | 32 | our @EXPORT_OK = qw(iterator result_number result_original); | |||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | # Croak at the line that called DBIx::Squirrel. | ||||||||||||||||||||||||||||
| 19 | 32 | our @CARP_NOT = @DBIx::Squirrel::Errors::INTERNAL; | |||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | # The iterator running the stages, set by the iterator while they run; a | ||||||||||||||||||||||||||||
| 22 | # package variable, so the iterator's next can localise it itself, | ||||||||||||||||||||||||||||
| 23 | # without a call for each row. | ||||||||||||||||||||||||||||
| 24 | 32 | our $ITERATOR; | |||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | # The iterator running the stage. | ||||||||||||||||||||||||||||
| 27 | 12 | ▶ | sub iterator : prototype() () { | ||||||||||||||||||||||||||
|
Subroutine
iterator: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 28 | 12 | return $ITERATOR; | |||||||||||||||||||||||||||
| 29 | } | ||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | # The number of the result being made, from 1: Ekorn's own sub, under our | ||||||||||||||||||||||||||||
| 32 | # name, as every run counts its results (roadmap 2026-0032, D1), so a | ||||||||||||||||||||||||||||
| 33 | # stage reading it pays for one call, not two. Ekorn's has an empty | ||||||||||||||||||||||||||||
| 34 | # prototype from v0.3.12, as ours always had, so result_number + 1 adds | ||||||||||||||||||||||||||||
| 35 | # one. | ||||||||||||||||||||||||||||
| 36 | 32 | *result_number = \&Ekorn::Pipeline::Context::result_number; | |||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | # The row the result is being made from, as it was fetched; undef for a | ||||||||||||||||||||||||||||
| 39 | # result a flush is making, which comes from every row: Ekorn's own sub, | ||||||||||||||||||||||||||||
| 40 | # under our name, as our statement source gives Ekorn the row as its | ||||||||||||||||||||||||||||
| 41 | # original part, which Ekorn passes through chains (roadmap 2026-0046). | ||||||||||||||||||||||||||||
| 42 | # Outside a run reading a statement, it's the value the run's source | ||||||||||||||||||||||||||||
| 43 | # gave (roadmap 2026-0032, D2). | ||||||||||||||||||||||||||||
| 44 | 32 | *result_original = \&Ekorn::Pipeline::Context::result_original; | |||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | # For DBIx::Squirrel's stages: the context of the run, if its source is a | ||||||||||||||||||||||||||||
| 47 | # statement, with its columns and the row it gave last; otherwise undef. | ||||||||||||||||||||||||||||
| 48 | 50 | ▶ | sub statement_context : prototype() () { | ||||||||||||||||||||||||||
|
Subroutine
statement_context: called CC=3 SCAR=11.1
Pod
documented
| |||||||||||||||||||||||||||||
| 49 | 50 | my $run = Ekorn::Pipeline::run_context(); | |||||||||||||||||||||||||||
| 50 | return is_plain_hashref($run) | ||||||||||||||||||||||||||||
| 51 | 50 | ▶ | && $run->{statement} isa 'DBIx::Squirrel::st' | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
Ref::Util::XS::is_plain_hashref($run) and $run->{"statement"} isa "DBIx::Squirrel::st"
MC/DC50%1/2
Ref::Util::XS::is_plain_hashref($run) and $run->{"statement"} isa "DBIx::Squirrel::st"
Ref::Util::XS::is_plain_hashref($run)
$run->{"statement"} isa "DBIx::Squirrel::st"
Truth table66%2/3
A and B
A= Ref::Util::XS::is_plain_hashref($run)B= $run->{"statement"} isa "DBIx::Squirrel::st"
| |||||||||||||||||||||||||||||
| 52 | ? $run | ||||||||||||||||||||||||||||
| 53 | : undef; | ||||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | # For DBIx::Squirrel's iterators: run code with the iterator given as the | ||||||||||||||||||||||||||||
| 57 | # one running, and return what it returns. | ||||||||||||||||||||||||||||
| 58 | 409 | ▶ | sub within ($iterator, $code) { | ||||||||||||||||||||||||||
|
Subroutine
within: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 59 | 409 | local $ITERATOR = $iterator; | |||||||||||||||||||||||||||
| 60 | 409 | return $code->(); | |||||||||||||||||||||||||||
| 61 | } | ||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | 32 | 1; | |||||||||||||||||||||||||||
| 64 | __END__ | ||||||||||||||||||||||||||||