Sybase/Storage/ASE/NoBindVars.pm

filter: Statementstmt 86.6% 39 / 45 Branchbran 70.0% 7 / 10 Conditioncond 44.4% 4 / 9 MC/DCmcdc 16.6% 1 / 6 Subroutinesub 73.3% 11 / 15 Podpod 100% 1 / 1 totaltotal 73.2% 63 / 86 CC 9 SCAR 12.8
CC
9
Cov
78%
interpolate_unquoted
8.0
_prep_interpolated_value
3.8
__ANON__
2.0
CRAP 3.6
« Sybase/SQLMaker.pm ↑ Summary Sybase/Quote.pm »
1 package DBIO::Sybase::Storage::ASE::NoBindVars;
2 # ABSTRACT: Support for Sybase ASE via DBD::Sybase without placeholders
3  
4 15 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 15 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 15 our $VERSION = '0.900007';
8  
9 15 ▶use base qw/
Subroutine BEGIN: called CC=1 SCAR=0.0
10 DBIO::Storage::DBI::NoBindVars
11 DBIO::Sybase::Storage::ASE
12 15 /;
13 15 ▶use mro 'c3';
Subroutine BEGIN: called CC=1 SCAR=0.0
14 15 ▶use Scalar::Util 'looks_like_number';
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 15 ▶use namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
17  
18  
19 39 ▶sub _init {
Subroutine _init: called CC=1 SCAR=0.0
20 39 my $self = shift;
21 39 $self->disable_sth_caching(1);
22 39 $self->_identity_method('@@IDENTITY');
23 39 $self->next::method(@_);
24 }
25  
26 27 ▶sub _fetch_identity_sql { 'SELECT ' . $_[0]->_identity_method }
Subroutine _fetch_identity_sql: called CC=1 SCAR=0.0
27  
28 0 ▶my $number = sub { looks_like_number $_[0] };
Subroutine __ANON__: not called CC=1 SCAR=1.2
29  
30 0 ▶my $decimal = sub { $_[0] =~ /^ [-+]? \d+ (?:\.\d*)? \z/x };
Subroutine __ANON__: not called CC=1 SCAR=1.2
31  
32 my %noquote = (
33 47 ▶ int => sub { $_[0] =~ /^ [-+]? \d+ \z/x },
Subroutine __ANON__: called CC=1 SCAR=0.0
34 0 ▶ bit => sub { $_[0] =~ /^[01]\z/ },
Subroutine __ANON__: not called CC=1 SCAR=6.9
35 0 ▶ money => sub { $_[0] =~ /^\$ \d+ (?:\.\d*)? \z/x },
Subroutine __ANON__: not called CC=1 SCAR=6.9
36 15 float => $number,
37 real => $number,
38 double => $number,
39 decimal => $decimal,
40 numeric => $decimal,
41 );
42  
43  
44 71 ▶sub interpolate_unquoted {
Subroutine interpolate_unquoted: called CC=7 SCAR=20.8
Pod documented
45 71 my $self = shift;
46 71 my ($type, $value) = @_;
47  
48 71 ▶ return $self->next::method(@_) if not defined $value or not defined $type;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $value and defined $type 1 70 71
Condition66%2/3
defined $value and defined $type
!ll&&!rl&&r
1070
MC/DC50%1/2
defined $value and defined $type
defined $value defined $type
Truth table66%2/3
A and B
A= defined $valueB= defined $type
ABresult
0X0
100
111
49  
50 70 ▶ if (my ($key) = grep { $type =~ /$_/i } keys %noquote) {
Branch: 2 branches
BranchTrueFalseTotal
if (my($key) = grep({$type =~ /$_/i;} keys %noquote)) { } 47 23 70
elsif ($self->is_datatype_numeric($type) and &$number($value)) { } 0 46 46
51 47 ▶ return 1 if $noquote{$key}->($value);
Branch: 1 branch
BranchTrueFalseTotal
if $noquote{$key}->($value) 47 0 47
52 }
53 ▶ elsif ($self->is_datatype_numeric($type) && $number->($value)) {
Condition33%1/3
$self->is_datatype_numeric($type) and &$number($value)
!ll&&!rl&&r
2300
MC/DC0%0/2
$self->is_datatype_numeric($type) and &$number($value)
$self->is_datatype_numeric($type) &$number($value)
Truth table33%1/3
A and B
A= $self->is_datatype_numeric($type)B= &$number($value)
ABresult
0X0
100
111
54 0 return 1;
55 }
56  
57 23 return $self->next::method(@_);
58 }
59  
60  
61 71 ▶sub _prep_interpolated_value {
Subroutine _prep_interpolated_value: called CC=3 SCAR=13.3
62 71 my ($self, $type, $value) = @_;
63  
64 71 ▶ if ($type =~ /money/i && defined $value) {
Branch: 1 branch
BranchTrueFalseTotal
if ($type =~ /money/i and defined $value) 0 71 71
Condition33%1/3
$type =~ /money/i and defined $value
!ll&&!rl&&r
7100
MC/DC0%0/2
$type =~ /money/i and defined $value
$type =~ /money/i defined $value
Truth table33%1/3
A and B
A= $type =~ /money/iB= defined $value
ABresult
0X0
100
111
65 # change a ^ not followed by \$ to a \$
66 0 $value =~ s/^ (?! \$) /\$/x;
67 }
68  
69 71 return $value;
70 }
71  
72  
73 15 1;
74  
75 __END__
« Sybase/SQLMaker.pm ↑ Summary Sybase/Quote.pm »