lib/SQL/Admin/Driver/Base/DBI.pm

filter: Statementstmt 48.3% 15 / 31 Branchbran 0.0% 0 / 4 Conditioncond 0.0% 0 / 20 MC/DCmcdc 0.0% 0 / 12 Subroutinesub 36.3% 4 / 11 Podpod 0.0% 0 / 7 totaltotal 22.3% 19 / 85 CC 10 SCAR 27.3
CC
10
Cov
27%
connect
42.0
new
6.0
sqla
6.0
CRAP 15.4
« lib/SQL/Admin/Driver/DB2/DBI.pm ↑ Summary lib/SQL/Admin/Driver/Base/Decompose.pm »
1  
2 package SQL::Admin::Driver::Base::DBI;
3  
4 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 1 our $VERSION = v0.5.0;
8  
9 ######################################################################
10  
11 1 ▶use DBI;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 1 ▶use SQL::Abstract;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 1 my $sqla;
15  
16 ######################################################################
17 ######################################################################
18 0 ▶sub new { # ;
Subroutine new: not called CC=2 SCAR=17.9
Pod undocumented
19 0 my $class = shift;
20 0 ▶ bless { @_ }, ref $class || $class;
Condition0%0/3
ref $class || $class
l!l&&r!l&&!r
000
MC/DC0%0/2
ref $class || $class
ref $class $class
Truth table0%0/3
A || B
A= ref $classB= $class
ABresult
1X1
011
000
21 }
22  
23  
24 ######################################################################
25 ######################################################################
26 0 ▶sub options { # ;
Subroutine options: not called CC=1 SCAR=6.9
Pod undocumented
27 (
28 0 'dbdns=s',
29 'dbusr=s',
30 'dbpwd=s',
31 );
32 }
33  
34  
35 ######################################################################
36 ######################################################################
37 0 ▶sub sqla { # ;
Subroutine sqla: not called CC=2 SCAR=17.9
Pod undocumented
38 0 ▶ $sqla ||= SQL::Abstract->new;
Condition0%0/3
$sqla ||= "SQL::Abstract"->new
l!l&&r!l&&!r
000
MC/DC0%0/2
$sqla ||= "SQL::Abstract"->new
$sqla "SQL::Abstract"->new
Truth table0%0/3
A ||= B
A= $sqlaB= "SQL::Abstract"->new
ABresult
1X1
011
000
39 }
40  
41  
42 ######################################################################
43 ######################################################################
44 0 ▶sub dbh { # ;
Subroutine dbh: not called CC=2 SCAR=17.9
Pod undocumented
45 0 my $self = shift;
46 0 ▶ $self->{dbh} || $self->connect;
Branch: 1 branch
BranchTrueFalseTotal
$self->{"dbh"} or $self->connect 0 0 0
47 }
48  
49  
50 ######################################################################
51 ######################################################################
52 0 ▶sub execute { # ;
Subroutine execute: not called CC=1 SCAR=6.9
Pod undocumented
53 0 my ($self, $sql, @bind) = @_;
54  
55 0 my $sth = $self->dbh->prepare ($sql);
56 0 $sth->execute (@bind);
57  
58 0 $sth;
59 }
60  
61  
62 ######################################################################
63 ######################################################################
64 0 ▶sub connect { # ;
Subroutine connect: not called CC=6 SCAR=37.4
Pod undocumented
65 0 my ($self, $dsn, $user, $password) = @_;
66  
67 $self->{dbh} ||= DBI->connect (
68 $dsn || $self->{dbdsn},
69 $user || $self->{dbusr},
70 $password || $self->{dbpwd},
71 0 ▶ { FetchHashKeyName => 'NAME_lc' },
Condition0%0/14
$self->{"dbh"} ||= "DBI"->connect($dsn || $self->{"dbdsn"}, $user || $self->{"dbusr"}, $password || $self->{"dbpwd"}, {"FetchHashKeyName", "NAME_lc"}) || die("Unable to connect: $DBI::errstr")
l!l&&r!l&&!r
000
'DBI'->connect($dsn || $self->{'dbdsn'}, $user || $self->{'dbusr'}, $password || $self->{'dbpwd'}, {'FetchHashKeyName', 'NAME_lc'}) || die("Unable to connect: $DBI::errstr")
l!l
00
$dsn || $self->{'dbdsn'}
l!l&&r!l&&!r
000
$user || $self->{'dbusr'}
l!l&&r!l&&!r
000
$password || $self->{'dbpwd'}
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->{"dbh"} ||= "DBI"->connect($dsn || $self->{"dbdsn"}, $user || $self->{"dbusr"}, $password || $self->{"dbpwd"}, {"FetchHashKeyName", "NAME_lc"}) || die("Unable to connect: $DBI::errstr")
$self->{"dbh"} 'DBI'->connect($dsn || $self->{'dbdsn'}, $user || $self->{'dbusr'}, $password || $self->{'dbpwd'}, {'FetchHashKeyName', 'NAME_lc'})
MC/DC0%0/2
$dsn || $self->{'dbdsn'}
$dsn $self->{'dbdsn'}
MC/DC0%0/2
$user || $self->{'dbusr'}
$user $self->{'dbusr'}
MC/DC0%0/2
$password || $self->{'dbpwd'}
$password $self->{'dbpwd'}
Truth table0%0/3
A ||= B
A= $self->{"dbh"}B= 'DBI'->connect($dsn || $self->{'dbdsn'}, $user || $self->{'dbusr'}, $password || $self->{'dbpwd'}, {'FetchHashKeyName', 'NAME_lc'})
ABresult
1X1
011
000
Truth table0%0/3
A || B
A= $dsnB= $self->{'dbdsn'}
ABresult
1X1
011
000
Truth table0%0/3
A || B
A= $userB= $self->{'dbusr'}
ABresult
1X1
011
000
Truth table0%0/3
A || B
A= $passwordB= $self->{'dbpwd'}
ABresult
1X1
011
000
72 ) || die "Unable to connect: $DBI::errstr";
73 }
74  
75  
76 ######################################################################
77 ######################################################################
78 0 ▶sub load { # ;
Subroutine load: not called CC=2 SCAR=17.9
Pod undocumented
79 0 my ($self, $catalog, @params) = @_;
80 0 ▶ $self->connect || return;
Branch: 1 branch
BranchTrueFalseTotal
$self->connect or return 0 0 0
81  
82 0 map $self->$_ ($catalog, @params),
83 grep $self->can ($_), (
84 'load_sequence',
85 'load_table',
86 'load_index',
87 'load_table_column',
88 'load_table_column_not_null',
89 'load_table_column_default',
90 'load_table_column_autoincrement',
91 'load_constraint_primary_key',
92 'load_constraint_unique',
93 'load_constraint_foreign_key',
94 'load_constraint_check',
95 # 'load_view',
96 # 'load_function',
97 # 'load_trigger',
98 # 'load_rule',
99 );
100  
101 0 1;
102 }
103  
104  
105 ######################################################################
106 ######################################################################
107  
108 package SQL::Admin::Driver::Base::DBI;
109  
110 1 1;
111  
« lib/SQL/Admin/Driver/DB2/DBI.pm ↑ Summary lib/SQL/Admin/Driver/Base/Decompose.pm »