| 1 | 5 | ▶ | use 5.008; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 2 | 5 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 3 | 5 | ▶ | use warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 4 | |||||||||||||||||||||
| 5 | package Data::Conveyor::Storage::DBI; | ||||||||||||||||||||
| 6 | 5 | ▶ | BEGIN { | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 7 | 5 | $Data::Conveyor::Storage::DBI::VERSION = '1.103130'; | |||||||||||||||||||
| 8 | } | ||||||||||||||||||||
| 9 | # ABSTRACT: Stage-based conveyor-belt-like ticket handling system | ||||||||||||||||||||
| 10 | |||||||||||||||||||||
| 11 | 5 | ▶ | use Error::Hierarchy::Internal::DBI::STH; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 12 | 5 | ▶ | use Error ':try'; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 13 | 5 | ▶ | use parent 'Data::Conveyor::Storage'; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 14 | 5 | __PACKAGE__->mk_scalar_accessors(qw(idcache)); | |||||||||||||||||||
| 15 | 5 | ▶ | use constant DEFAULTS => (idcache => {},); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 16 | |||||||||||||||||||||
| 17 | # Subclasses could override this to rethrow certain ::DBI::STH exceptions as | ||||||||||||||||||||
| 18 | # something more specific to the workflow system at hand. | ||||||||||||||||||||
| 19 | 0 | ▶ | sub ticket_handle_exception { | ||||||||||||||||||
|
Subroutine
ticket_handle_exception: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 20 | 0 | my ($self, $E) = @_; | |||||||||||||||||||
| 21 | 0 | throw $E; | |||||||||||||||||||
| 22 | } | ||||||||||||||||||||
| 23 | |||||||||||||||||||||
| 24 | 0 | ▶ | sub ticket_update { | ||||||||||||||||||
|
Subroutine
ticket_update: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 25 | 0 | my ($self, $ticket) = @_; | |||||||||||||||||||
| 26 | 0 | ▶ | try { | ||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||
| 27 | 0 | $self->_ticket_update($ticket); | |||||||||||||||||||
| 28 | } | ||||||||||||||||||||
| 29 | 0 | ▶ | catch Error::Hierarchy::Internal::DBI::STH with { | ||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||
| 30 | 0 | $self->ticket_handle_exception($_[0], $ticket); | |||||||||||||||||||
| 31 | 0 | }; | |||||||||||||||||||
| 32 | 0 | $ticket; | |||||||||||||||||||
| 33 | } | ||||||||||||||||||||
| 34 | |||||||||||||||||||||
| 35 | 0 | ▶ | sub ticket_insert { | ||||||||||||||||||
|
Subroutine
ticket_insert: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 36 | 0 | my ($self, $ticket) = @_; | |||||||||||||||||||
| 37 | 0 | ▶ | try { | ||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||
| 38 | 0 | $self->_ticket_insert($ticket); | |||||||||||||||||||
| 39 | } | ||||||||||||||||||||
| 40 | 0 | ▶ | catch Error::Hierarchy::Internal::DBI::STH with { | ||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||
| 41 | 0 | $self->ticket_handle_exception($_[0], $ticket); | |||||||||||||||||||
| 42 | 0 | }; | |||||||||||||||||||
| 43 | 0 | $ticket; | |||||||||||||||||||
| 44 | } | ||||||||||||||||||||
| 45 | |||||||||||||||||||||
| 46 | 0 | ▶ | sub cached_statement { | ||||||||||||||||||
|
Subroutine
cached_statement: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||
| 47 | 0 | my ($self, $args) = @_; | |||||||||||||||||||
| 48 | |||||||||||||||||||||
| 49 | # The result will be an aarray of hashrefs; one element per returned row; | ||||||||||||||||||||
| 50 | # each row has a column hash. | ||||||||||||||||||||
| 51 | # To compute $argstr, dereference as an array, not a hash, because hash | ||||||||||||||||||||
| 52 | # sort order is not defined. | ||||||||||||||||||||
| 53 | 0 | my $argstr = join $;, %{ $args->{args} }; | |||||||||||||||||||
| 54 | 0 | ▶ | return $self->cache->{ $args->{name} }{$argstr} ||= do { | ||||||||||||||||||
|
Condition0%0/3
$self->cache->{$args->{"name"}}{$argstr} ||= do {
my(@result, %row);
my $sth = $self->prepare_named($args->{"name"}, $args->{"SQL"});
while (() = each %{$args->{"param"} or {};}) {
do {
$sth->bind_param(":$key", $args->{"args"}{$key}, $type)
};
};
$sth->execute;
$sth->bind_columns(map({\$row{$_};} @{$$args{"fields"};}));
while ($sth->fetch) {
push @result, \%row;
};
$sth->finish;
\@result
}
MC/DC0%0/2
$self->cache->{$args->{"name"}}{$argstr} ||= do {
my(@result, %row);
my $sth = $self->prepare_named($args->{"name"}, $args->{"SQL"});
while (() = each %{$args->{"param"} or {};}) {
do {
$sth->bind_param(":$key", $args->{"args"}{$key}, $type)
};
};
$sth->execute;
$sth->bind_columns(map({\$row{$_};} @{$$args{"fields"};}));
while ($sth->fetch) {
push @result, \%row;
};
$sth->finish;
\@result
}
$self->cache->{$args->{"name"}}{$argstr}
do {
my(@result, %row);
my $sth = $self->prepare_named($args->{"name"}, $args->{"SQL"});
while (() = each %{$args->{"param"} or {};}) {
do {
$sth->bind_param(":$key", $args->{"args"}{$key}, $type)
};
};
$sth->execute;
$sth->bind_columns(map({\$row{$_};} @{$$args{"fields"};}));
while ($sth->fetch) {
push @result, \%row;
};
$sth->finish;
\@result
}
Truth table0%0/3
A ||= B
A= $self->cache->{$args->{"name"}}{$argstr}B= do {
my(@result, %row);
my $sth = $self->prepare_named($args->{"name"}, $args->{"SQL"});
while (() = each %{$args->{"param"} or {};}) {
do {
$sth->bind_param(":$key", $args->{"args"}{$key}, $type)
};
};
$sth->execute;
$sth->bind_columns(map({\$row{$_};} @{$$args{"fields"};}));
while ($sth->fetch) {
push @result, \%row;
};
$sth->finish;
\@result
}
| |||||||||||||||||||||
| 55 | 0 | my (@result, %row); | |||||||||||||||||||
| 56 | 0 | my $sth = $self->prepare_named($args->{name} => $args->{SQL}); | |||||||||||||||||||
| 57 | 0 | ▶ | while (my ($key, $type) = each %{ $args->{param} || {} }) { | ||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
$args->{'param'} || {}
MC/DC0%0/1
$args->{'param'} || {}
$args->{'param'}
Truth table0%0/2
A
A= $args->{'param'}
| |||||||||||||||||||||
| 58 | 0 | $sth->bind_param(":$key", $args->{args}{$key}, $type); | |||||||||||||||||||
| 59 | } | ||||||||||||||||||||
| 60 | 0 | $sth->execute; | |||||||||||||||||||
| 61 | 0 | $sth->bind_columns(map { \$row{$_} } @{ $args->{fields} }); | |||||||||||||||||||
| 62 | 0 | ▶ | while ($sth->fetch) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 63 | 0 | push @result => \%row; | |||||||||||||||||||
| 64 | } | ||||||||||||||||||||
| 65 | 0 | $sth->finish; | |||||||||||||||||||
| 66 | 0 | \@result; | |||||||||||||||||||
| 67 | } | ||||||||||||||||||||
| 68 | } | ||||||||||||||||||||
| 69 | 5 | 1; | |||||||||||||||||||
| 70 | |||||||||||||||||||||
| 71 | |||||||||||||||||||||
| 72 | __END__ | ||||||||||||||||||||