blib/lib/DBIO/Storage/DBI/AutoCast.pm

filter: Statementstmt 100% 27 / 27 Branchbran 75.0% 3 / 4 Conditioncond 66.6% 2 / 3 MC/DCmcdc 50.0% 1 / 2 Subroutinesub 100% 6 / 6 Podpod 100% 1 / 1 totaltotal 93.0% 40 / 43 CC 5 SCAR 11.1
CC
5
Cov
94%
_prep_for_execute
5.0
BEGIN
1.0
BEGIN
1.0
CRAP 3.0
« blib/lib/DBIO/Base.pm ↑ Summary blib/lib/DBIO/ResultSet/Pager.pm »
1 package DBIO::Storage::DBI::AutoCast;
2 # ABSTRACT: Storage component for RDBMS requiring explicit placeholder typing
3  
4 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 4 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 4 our $VERSION = '0.900007';
8  
9 4 ▶use base qw/DBIO::Storage::DBI/;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 4 ▶use mro 'c3';
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 4 __PACKAGE__->mk_group_accessors('simple' => 'auto_cast' );
13  
14  
15  
16 2 ▶sub _prep_for_execute {
Subroutine _prep_for_execute: called CC=5 SCAR=16.2
17 2 my $self = shift;
18  
19 2 my ($sql, $bind) = $self->next::method (@_);
20  
21 # If we're using ::NoBindVars, there are no binds by this point so this code
22 # gets skipped.
23 2 ▶ if ($self->auto_cast && @$bind) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->auto_cast and @$bind) 1 1 2
Condition66%2/3
$self->auto_cast and @$bind
!ll&&!rl&&r
101
MC/DC50%1/2
$self->auto_cast and @$bind
$self->auto_cast @$bind
Truth table66%2/3
A and B
A= $self->auto_castB= @$bind
ABresult
0X0
100
111
24 1 my $new_sql;
25 1 my @sql_part = split /\?/, $sql, scalar @$bind + 1;
26 1 for (@$bind) {
27 2 my $cast_type = $self->_native_data_type($_->[0]{sqlt_datatype});
28 2 ▶ $new_sql .= shift(@sql_part) . ($cast_type ? "CAST(? AS $cast_type)" : '?');
Branch: 1 branch
BranchTrueFalseTotal
$cast_type ? : 2 0 2
29 }
30 1 $sql = $new_sql . shift @sql_part;
31 }
32  
33 2 return ($sql, $bind);
34 }
35  
36  
37 1 ▶sub connect_call_set_auto_cast {
Subroutine connect_call_set_auto_cast: called CC=1 SCAR=0.0
Pod documented
38 1 my $self = shift;
39 1 $self->auto_cast(1);
40 }
41  
42  
43 4 1;
44  
45 __END__
« blib/lib/DBIO/Base.pm ↑ Summary blib/lib/DBIO/ResultSet/Pager.pm »