NAME
DBIx::Squirrel::Context - what a stage can ask about the result it's making
SYNOPSIS
use DBIx::Squirrel::Context qw(result_number result_original);
my $it = $dbh->iterate(
'SELECT name FROM artist ORDER BY name',
sub ($row) { "@{[ result_number ]}. $row->[0]" },
);
DESCRIPTION
Inside a stage, these functions tell the stage about the result it's making: things it can't work out from the value it's given. "result_original" works in any run reading a statement: an iterator's own stages, and those of a chain made with |, or of a pipeline of yours, reading one. "result_number" and "iterator" work only in an iterator's own stages, run by its next, all, first or single. Elsewhere, and outside a stage, they return undef. None is exported by default.
FUNCTIONS
iterator
The iterator running the stage, in its own stages. Its sth is the statement handle, and the statement handle's Database is the database handle.
result_number
The number of the result being made, from 1. It counts results, not rows. While a stage drops rows, the number stays the same. Each value a stage returns in place of one row is a result of its own. In a flush of a stage made with DBIx::Squirrel::Gather, it's the number of the first value the flush returns. It's there only in an iterator's own stages, as only the iterator counts its results.
result_original
The row the result is being made from, as it was fetched, before any stage changed it. In a flush of a stage made with DBIx::Squirrel::Gather, and the stages after it, it's undef. What a flush gives comes from every row, not one. The statement's source keeps the row in its run's context, so it's there wherever a statement is read.
statement_context
For DBIx::Squirrel's stages, which read a statement's columns from the run they're in. It's not for use elsewhere.
within
For DBIx::Squirrel's iterators, which set the context while their stages run. It's not for use elsewhere.
SEE ALSO
DBIx::Squirrel::Iterator, Ekorn::Pipeline
AUTHOR
Iain Campbell <cpanic@cpan.org>
LICENSE
Copyright (c) 2024-2026 by Iain Campbell.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.