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

filter: Statementstmt 59.4% 22 / 37 Branchbran 0.0% 0 / 10 Conditioncond 0.0% 0 / 12 MC/DCmcdc 0.0% 0 / 5 Subroutinesub 70.0% 7 / 10 Podpod n/a totaltotal 39.1% 29 / 74 CC 11 SCAR 28.4
CC
11
Cov
37%
_using_freetds
30.0
_disable_odbc_array_ops
30.0
_using_freetds_version
12.0
CRAP 17.1
« blib/lib/DBIO/Generate/Style/Cake.pm ↑ Summary blib/lib/DBIO/Cake.pm »
1 package DBIO::Storage::DBI::ODBC;
2 # ABSTRACT: Base class for ODBC drivers
3 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 4 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 4 our $VERSION = '0.900007';
7  
8 4 ▶use base qw/DBIO::Storage::DBI/;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 4 ▶use mro 'c3';
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 4 ▶use DBIO::Util 'modver_gt_or_eq';
Subroutine BEGIN: called CC=1 SCAR=0.0
12 4 ▶use namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14  
15 # Whether or not we are connecting via the freetds ODBC driver
16 0 ▶sub _using_freetds {
Subroutine _using_freetds: not called CC=5 SCAR=34.0
17 0 my $self = shift;
18  
19 0 my $dsn = $self->_dbi_connect_info->[0];
20  
21 0 ▶ return 1 if (
Branch: 1 branch
BranchTrueFalseTotal
if not ref $dsn and $dsn =~ /driver=FreeTDS/i or ($self->_dbh_get_info("SQL_DRIVER_NAME") || "") =~ /tdsodbc/i 0 0 0
Condition0%0/8
not ref $dsn and $dsn =~ /driver=FreeTDS/i or ($self->_dbh_get_info("SQL_DRIVER_NAME") || "") =~ /tdsodbc/i
l!l&&r!l&&!r
000
not ref $dsn and $dsn =~ /driver=FreeTDS/i
!ll&&!rl&&r
000
$self->_dbh_get_info('SQL_DRIVER_NAME') || ''
l!l
00
MC/DC0%0/3
not ref $dsn and $dsn =~ /driver=FreeTDS/i or ($self->_dbh_get_info("SQL_DRIVER_NAME") || "") =~ /tdsodbc/i
not ref $dsn $dsn =~ /driver=FreeTDS/i $self->_dbh_get_info('SQL_DRIVER_NAME')
Truth table0%0/5
not(A) and B or C
A= not ref $dsnB= $dsn =~ /driver=FreeTDS/iC= $self->_dbh_get_info('SQL_DRIVER_NAME')
ABCresult
11X1
0X11
1011
0X00
1000
22 ( (! ref $dsn) and $dsn =~ /driver=FreeTDS/i)
23 or
24 ( ($self->_dbh_get_info('SQL_DRIVER_NAME')||'') =~ /tdsodbc/i )
25 );
26  
27 0 return 0;
28 }
29  
30  
31 # Either returns the FreeTDS version via which we are connecting, 0 if can't
32 # be determined, or undef otherwise
33 0 ▶sub _using_freetds_version {
Subroutine _using_freetds_version: not called CC=3 SCAR=24.8
34 0 my $self = shift;
35 0 ▶ return undef unless $self->_using_freetds;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_using_freetds 0 0 0
36 0 ▶ return $self->_dbh_get_info('SQL_DRIVER_VER') || 0;
Condition0%0/2
$self->_dbh_get_info('SQL_DRIVER_VER') || 0
l!l
00
MC/DC0%0/1
$self->_dbh_get_info('SQL_DRIVER_VER') || 0
$self->_dbh_get_info('SQL_DRIVER_VER')
Truth table0%0/2
A
A= $self->_dbh_get_info('SQL_DRIVER_VER')
Aresult
11
00
37 }
38  
39  
40 0 ▶sub _disable_odbc_array_ops {
Subroutine _disable_odbc_array_ops: not called CC=5 SCAR=34.0
41 0 my $self = shift;
42 0 my $dbh = $self->_get_dbh;
43  
44 0 ▶ $DBD::ODBC::__DBIO_DISABLE_ARRAY_OPS_VIA__ ||= [ do {
Condition0%0/2
$DBD::ODBC::__DBIO_DISABLE_ARRAY_OPS_VIA__ ||= [do { if (&modver_gt_or_eq("DBD::ODBC", "1.35_01")) { "odbc_array_operations", 0; } elsif (&modver_gt_or_eq("DBD::ODBC", "1.33_01")) { "odbc_disable_array_operations", 1; } }]
l!l
00
MC/DC0%0/1
$DBD::ODBC::__DBIO_DISABLE_ARRAY_OPS_VIA__ ||= [do { if (&modver_gt_or_eq("DBD::ODBC", "1.35_01")) { "odbc_array_operations", 0; } elsif (&modver_gt_or_eq("DBD::ODBC", "1.33_01")) { "odbc_disable_array_operations", 1; } }]
$DBD::ODBC::__DBIO_DISABLE_ARRAY_OPS_VIA__
Truth table0%0/2
A
A= $DBD::ODBC::__DBIO_DISABLE_ARRAY_OPS_VIA__
Aresult
11
00
45 0 ▶ if( modver_gt_or_eq('DBD::ODBC', '1.35_01') ) {
Branch: 2 branches
BranchTrueFalseTotal
if (&modver_gt_or_eq('DBD::ODBC', '1.35_01')) { } 0 0 0
elsif (&modver_gt_or_eq('DBD::ODBC', '1.33_01')) { } 0 0 0
46 0 odbc_array_operations => 0;
47 }
48 elsif( modver_gt_or_eq('DBD::ODBC', '1.33_01') ) {
49 0 odbc_disable_array_operations => 1;
50 }
51 }];
52  
53 0 ▶ if (my ($k, $v) = @$DBD::ODBC::__DBIO_DISABLE_ARRAY_OPS_VIA__) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = @$DBD::ODBC::__DBIO_DISABLE_ARRAY_OPS_VIA__) 0 0 0
54 0 $dbh->{$k} = $v;
55 }
56 }
57  
58  
59 1 ▶sub _connect_params_dsn {
Subroutine _connect_params_dsn: called CC=1 SCAR=0.0
60 1 my $self = shift;
61 1 $self->throw_exception(
62 'Cannot build a DBD::ODBC DSN from connection parameters (dbname, host, '
63 . 'port): DBD::ODBC connects through a data source name (dbi:ODBC:DSN=...) '
64 . 'or a connection string naming the ODBC driver (dbi:ODBC:Driver=...;...), '
65 . 'and connection parameters carry neither. Give the whole DSN instead -- '
66 . 'as dsn, or as a dbname starting with dbi:ODBC: -- or use an AccessBroker '
67 . 'that answers in DBI form ([ $dsn, $user, $password ]).'
68 );
69 }
70  
71  
72 4 1;
73  
74 # vim:sts=2 sw=2:
75  
76 __END__
« blib/lib/DBIO/Generate/Style/Cake.pm ↑ Summary blib/lib/DBIO/Cake.pm »