| 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
Condition66%2/3
defined $value and defined $type
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
| |||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | 70 | ▶ | if (my ($key) = grep { $type =~ /$_/i } keys %noquote) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 51 | 47 | ▶ | return 1 if $noquote{$key}->($value); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||
| 53 | ▶ | elsif ($self->is_datatype_numeric($type) && $number->($value)) { | |||||||||||||||||||||||||||
|
Condition33%1/3
$self->is_datatype_numeric($type) and &$number($value)
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)
| |||||||||||||||||||||||||||||
| 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
Condition33%1/3
$type =~ /money/i and defined $value
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
| |||||||||||||||||||||||||||||
| 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__ | ||||||||||||||||||||||||||||