DBIx/Class/Storage/DBI/Sybase/ASE/NoBindVars.pm

filter: Statementstmt 50.0% 22 / 44 Branchbran 0.0% 0 / 10 Conditioncond 0.0% 0 / 9 MC/DCmcdc 0.0% 0 / 6 Subroutinesub 40.0% 6 / 15 Podpod 100% 1 / 1 totaltotal 34.1% 29 / 85 CC 9 SCAR 29.7
CC
9
Cov
35%
interpolate_unquoted
56.0
_prep_interpolated_value
12.0
_init
2.0
CRAP 19.4
« DBIx/Class/Storage/DBI/SQLAnywhere/Cursor.pm ↑ Summary DBIx/Class/ResultSource/RowParser.pm »
1 package DBIx::Class::Storage::DBI::Sybase::ASE::NoBindVars;
2  
3 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 2 ▶use base qw/
Subroutine BEGIN: called CC=1 SCAR=0.0
7 DBIx::Class::Storage::DBI::NoBindVars
8 DBIx::Class::Storage::DBI::Sybase::ASE
9 2 /;
10 2 ▶use mro 'c3';
Subroutine BEGIN: called CC=1 SCAR=0.0
11 2 ▶use Scalar::Util 'looks_like_number';
Subroutine BEGIN: called CC=1 SCAR=0.0
12 2 ▶use namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 0 ▶sub _init {
Subroutine _init: not called CC=1 SCAR=6.9
15 0 my $self = shift;
16 0 $self->disable_sth_caching(1);
17 0 $self->_identity_method('@@IDENTITY');
18 0 $self->next::method (@_);
19 }
20  
21 0 ▶sub _fetch_identity_sql { 'SELECT ' . $_[0]->_identity_method }
Subroutine _fetch_identity_sql: not called CC=1 SCAR=6.9
22  
23 0 ▶my $number = sub { looks_like_number $_[0] };
Subroutine __ANON__: not called CC=1 SCAR=1.2
24  
25 0 ▶my $decimal = sub { $_[0] =~ /^ [-+]? \d+ (?:\.\d*)? \z/x };
Subroutine __ANON__: not called CC=1 SCAR=1.2
26  
27 my %noquote = (
28 0 ▶ int => sub { $_[0] =~ /^ [-+]? \d+ \z/x },
Subroutine __ANON__: not called CC=1 SCAR=6.9
29 0 ▶ bit => => sub { $_[0] =~ /^[01]\z/ },
Subroutine __ANON__: not called CC=1 SCAR=6.9
30 0 ▶ money => sub { $_[0] =~ /^\$ \d+ (?:\.\d*)? \z/x },
Subroutine __ANON__: not called CC=1 SCAR=6.9
31 2 float => $number,
32 real => $number,
33 double => $number,
34 decimal => $decimal,
35 numeric => $decimal,
36 );
37  
38 0 ▶sub interpolate_unquoted {
Subroutine interpolate_unquoted: not called CC=7 SCAR=40.3
Pod documented
39 0 my $self = shift;
40 0 my ($type, $value) = @_;
41  
42 0 ▶ return $self->next::method(@_) if not defined $value or not defined $type;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $value and defined $type 0 0 0
Condition0%0/3
defined $value and defined $type
!ll&&!rl&&r
000
MC/DC0%0/2
defined $value and defined $type
defined $value defined $type
Truth table0%0/3
A and B
A= defined $valueB= defined $type
ABresult
0X0
100
111
43  
44 0 ▶ if (my ($key) = grep { $type =~ /$_/i } keys %noquote) {
Branch: 2 branches
BranchTrueFalseTotal
if (my($key) = grep({$type =~ /$_/i;} keys %noquote)) { } 0 0 0
elsif ($self->is_datatype_numeric($type) and &$number($value)) { } 0 0 0
45 0 ▶ return 1 if $noquote{$key}->($value);
Branch: 1 branch
BranchTrueFalseTotal
if $noquote{$key}->($value) 0 0 0
46 }
47 ▶ elsif ($self->is_datatype_numeric($type) && $number->($value)) {
Condition0%0/3
$self->is_datatype_numeric($type) and &$number($value)
!ll&&!rl&&r
000
MC/DC0%0/2
$self->is_datatype_numeric($type) and &$number($value)
$self->is_datatype_numeric($type) &$number($value)
Truth table0%0/3
A and B
A= $self->is_datatype_numeric($type)B= &$number($value)
ABresult
0X0
100
111
48 0 return 1;
49 }
50  
51 0 return $self->next::method(@_);
52 }
53  
54 0 ▶sub _prep_interpolated_value {
Subroutine _prep_interpolated_value: not called CC=3 SCAR=24.8
55 0 my ($self, $type, $value) = @_;
56  
57 0 ▶ if ($type =~ /money/i && defined $value) {
Branch: 1 branch
BranchTrueFalseTotal
if ($type =~ /money/i and defined $value) 0 0 0
Condition0%0/3
$type =~ /money/i and defined $value
!ll&&!rl&&r
000
MC/DC0%0/2
$type =~ /money/i and defined $value
$type =~ /money/i defined $value
Truth table0%0/3
A and B
A= $type =~ /money/iB= defined $value
ABresult
0X0
100
111
58 # change a ^ not followed by \$ to a \$
59 0 $value =~ s/^ (?! \$) /\$/x;
60 }
61  
62 0 return $value;
63 }
64  
65 2 1;
66  
67 =head1 NAME
68  
69 DBIx::Class::Storage::DBI::Sybase::ASE::NoBindVars - Storage::DBI subclass for
70 Sybase ASE without placeholder support
71  
72 =head1 DESCRIPTION
73  
74 If you're using this driver then your version of Sybase or the libraries you
75 use to connect to it do not support placeholders.
76  
77 You can also enable this driver explicitly using:
78  
79 my $schema = SchemaClass->clone;
80 $schema->storage_type('::DBI::Sybase::ASE::NoBindVars');
81 $schema->connect($dsn, $user, $pass, \%opts);
82  
83 See the discussion in
84 L<< DBD::Sybase/Using ? Placeholders & bind parameters to $sth->execute >>
85 for details on the pros and cons of using placeholders with this particular
86 driver.
87  
88 One advantage of not using placeholders is that C<select @@identity> will work
89 for obtaining the last insert id of an C<IDENTITY> column, instead of having to
90 do C<select max(col)> in a transaction as the base Sybase driver does.
91  
92 When using this driver, bind variables will be interpolated (properly quoted of
93 course) into the SQL query itself, without using placeholders.
94  
95 The caching of prepared statements is also explicitly disabled, as the
96 interpolation renders it useless.
97  
98 =head1 FURTHER QUESTIONS?
99  
100 Check the list of L<additional DBIC resources|DBIx::Class/GETTING HELP/SUPPORT>.
101  
102 =head1 COPYRIGHT AND LICENSE
103  
104 This module is free software L<copyright|DBIx::Class/COPYRIGHT AND LICENSE>
105 by the L<DBIx::Class (DBIC) authors|DBIx::Class/AUTHORS>. You can
106 redistribute it and/or modify it under the same terms as the
107 L<DBIx::Class library|DBIx::Class/COPYRIGHT AND LICENSE>.
« DBIx/Class/Storage/DBI/SQLAnywhere/Cursor.pm ↑ Summary DBIx/Class/ResultSource/RowParser.pm »