DBIx/Class/Storage/DBI/Sybase.pm

filter: Statementstmt 35.8% 24 / 67 Branchbran 4.5% 1 / 22 Conditioncond 22.2% 2 / 9 MC/DCmcdc 0.0% 0 / 5 Subroutinesub 53.3% 8 / 15 Podpod n/a totaltotal 29.6% 35 / 118 CC 16 SCAR 25.3
CC
16
Cov
28%
_set_max_connect
30.0
_rebless
20.0
_using_freetds_version
20.0
CRAP 12.6
« DBIx/Class/Storage/DBI/DB2.pm ↑ Summary DBIx/Class/ResultSourceProxy/Table.pm »
1 package DBIx::Class::Storage::DBI::Sybase;
2  
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 4 ▶use Try::Tiny;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 4 ▶use namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 4 ▶use base qw/DBIx::Class::Storage::DBI/;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 =head1 NAME
11  
12 DBIx::Class::Storage::DBI::Sybase - Base class for drivers using
13 L<DBD::Sybase>
14  
15 =head1 DESCRIPTION
16  
17 This is the base class/dispatcher for Storage's designed to work with
18 L<DBD::Sybase>
19  
20 =head1 METHODS
21  
22 =cut
23  
24 0 ▶sub _rebless {
Subroutine _rebless: not called CC=4 SCAR=30.0
25 0 my $self = shift;
26  
27 0 my $dbtype;
28 0 ▶ try {
Subroutine __ANON__: not called CC=1 SCAR=6.9
29 0 $dbtype = @{$self->_get_dbh->selectrow_arrayref(qq{sp_server_info \@attribute_id=1})}[2]
30 0 ▶ } catch {
Subroutine __ANON__: not called CC=1 SCAR=6.9
31 0 $self->throw_exception("Unable to establish connection to determine database type: $_")
32 0 };
33  
34 0 ▶ if ($dbtype) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dbtype) 0 0 0
35 0 $dbtype =~ s/\W/_/gi;
36  
37 # saner class name
38 0 ▶ $dbtype = 'ASE' if $dbtype eq 'SQL_Server';
Branch: 1 branch
BranchTrueFalseTotal
if $dbtype eq "SQL_Server" 0 0 0
39  
40 0 my $subclass = __PACKAGE__ . "::$dbtype";
41 0 ▶ if ($self->load_optional_class($subclass)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->load_optional_class($subclass)) 0 0 0
42 0 bless $self, $subclass;
43 0 $self->_rebless;
44 }
45 }
46 }
47  
48 1 ▶sub _init {
Subroutine _init: called CC=3 SCAR=16.7
49 # once the driver is determined see if we need to insert the DBD::Sybase w/ FreeTDS fixups
50 # this is a dirty version of "instance role application", \o/ DO WANT Moo \o/
51 1 my $self = shift;
52 1 ▶ if (! $self->isa('DBIx::Class::Storage::DBI::Sybase::FreeTDS') and $self->_using_freetds) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $self->isa("DBIx::Class::Storage::DBI::Sybase::FreeTDS") and $self->_using_freetds) 0 1 1
Condition33%1/3
not $self->isa("DBIx::Class::Storage::DBI::Sybase::FreeTDS") and $self->_using_freetds
!ll&&!rl&&r
010
MC/DC0%0/2
not $self->isa("DBIx::Class::Storage::DBI::Sybase::FreeTDS") and $self->_using_freetds
not $self->isa("DBIx::Class::Storage::DBI::Sybase::FreeTDS") $self->_using_freetds
Truth table33%1/3
not(A) and B
A= not $self->isa("DBIx::Class::Storage::DBI::Sybase::FreeTDS")B= $self->_using_freetds
ABresult
0X0
100
111
53 0 require DBIx::Class::Storage::DBI::Sybase::FreeTDS;
54  
55 0 my @isa = @{mro::get_linear_isa(ref $self)};
56 0 my $class = shift @isa; # this is our current ref
57  
58 0 my $trait_class = $class . '::FreeTDS';
59 0 mro::set_mro ($trait_class, 'c3');
60 4 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
61 0 @{"${trait_class}::ISA"} = ($class, 'DBIx::Class::Storage::DBI::Sybase::FreeTDS', @isa);
62  
63 0 bless ($self, $trait_class);
64  
65 0 Class::C3->reinitialize() if DBIx::Class::_ENV_::OLD_MRO;
66  
67 0 $self->_init(@_);
68 }
69  
70 1 $self->next::method(@_);
71 }
72  
73 0 ▶sub _ping {
Subroutine _ping: not called CC=3 SCAR=24.8
74 0 my $self = shift;
75  
76 0 ▶ my $dbh = $self->_dbh or return 0;
Branch: 1 branch
BranchTrueFalseTotal
my $dbh = $self->_dbh or return 0 0 0 0
77  
78 0 local $dbh->{RaiseError} = 1;
79 0 local $dbh->{PrintError} = 0;
80  
81 0 ▶ ( try { $dbh->do('select 1'); 1 } )
Subroutine __ANON__: not called CC=1 SCAR=6.9
82 0 ▶ ? 1
Branch: 1 branch
BranchTrueFalseTotal
&try(sub { $dbh->do('select 1'); 1; } ) ? : 0 0 0
83 : 0
84 ;
85 }
86  
87 0 ▶sub _set_max_connect {
Subroutine _set_max_connect: not called CC=5 SCAR=34.0
88 0 my $self = shift;
89 0 ▶ my $val = shift || 256;
Condition0%0/2
shift() || 256
l!l
00
MC/DC0%0/1
shift() || 256
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
90  
91 0 my $dsn = $self->_dbi_connect_info->[0];
92  
93 0 ▶ return if ref($dsn) eq 'CODE';
Branch: 1 branch
BranchTrueFalseTotal
if ref $dsn eq "CODE" 0 0 0
94  
95 0 ▶ if ($dsn !~ /maxConnect=/) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $dsn =~ /maxConnect=/) 0 0 0
96 0 $self->_dbi_connect_info->[0] = "$dsn;maxConnect=$val";
97 0 my $connected = defined $self->_dbh;
98 0 $self->disconnect;
99 0 ▶ $self->ensure_connected if $connected;
Branch: 1 branch
BranchTrueFalseTotal
if $connected 0 0 0
100 }
101 }
102  
103 # Whether or not DBD::Sybase was compiled against FreeTDS. If false, it means
104 # the Sybase OpenClient libraries were used.
105 2 ▶sub _using_freetds {
Subroutine _using_freetds: called CC=2 SCAR=7.2
106 2 my $self = shift;
107 2 ▶ return ($self->_get_dbh->{syb_oc_version}||'') =~ /freetds/i;
Condition50%1/2
$self->_get_dbh->{'syb_oc_version'} || ''
l!l
02
MC/DC0%0/1
$self->_get_dbh->{'syb_oc_version'} || ''
$self->_get_dbh->{'syb_oc_version'}
Truth table50%1/2
A
A= $self->_get_dbh->{'syb_oc_version'}
Aresult
11
00
108 }
109  
110 # Either returns the FreeTDS version against which DBD::Sybase was compiled,
111 # 0 if can't be determined, or undef otherwise
112 0 ▶sub _using_freetds_version {
Subroutine _using_freetds_version: not called CC=4 SCAR=30.0
113 0 my $inf = shift->_get_dbh->{syb_oc_version};
114 0 ▶ return undef unless ($inf||'') =~ /freetds/i;
Branch: 1 branch
BranchTrueFalseTotal
unless ($inf || "") =~ /freetds/i 0 0 0
Condition0%0/2
$inf || ''
l!l
00
MC/DC0%0/1
$inf || ''
$inf
Truth table0%0/2
A
A= $inf
Aresult
11
00
115 0 ▶ return $inf =~ /v([0-9\.]+)/ ? $1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$inf =~ /v([0-9\.]+)/ ? : 0 0 0
116 }
117  
118 =head1 FURTHER QUESTIONS?
119  
120 Check the list of L<additional DBIC resources|DBIx::Class/GETTING HELP/SUPPORT>.
121  
122 =head1 COPYRIGHT AND LICENSE
123  
124 This module is free software L<copyright|DBIx::Class/COPYRIGHT AND LICENSE>
125 by the L<DBIx::Class (DBIC) authors|DBIx::Class/AUTHORS>. You can
126 redistribute it and/or modify it under the same terms as the
127 L<DBIx::Class library|DBIx::Class/COPYRIGHT AND LICENSE>.
128  
129 =cut
130  
131 4 1;
132  
« DBIx/Class/Storage/DBI/DB2.pm ↑ Summary DBIx/Class/ResultSourceProxy/Table.pm »