Loader/DBI.pm

filter: Statementstmt 88.5% 31 / 35 Branchbran 75.0% 6 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 75.0% 6 / 8 Podpod 0.0% 0 / 5 totaltotal 76.7% 43 / 56 CC 6 SCAR 9.4
CC
6
Cov
86%
new
4.1
table_pk
3.0
quoter
2.0
CRAP 2.6
« Loader/DBI/SQLite.pm ↑ Summary
1 package DBIx::Skinny::Schema::Loader::DBI;
2 15 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 15 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5  
6 15 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 16 ▶sub new {
Subroutine new: called CC=4 SCAR=14.1
Pod undocumented
9 16 my ($class, $fields) = @_;
10 16 ▶ $fields = {} unless defined $fields;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $fields 0 16 16
11 16 for ( qw/dsn user pass/ ) {
12 48 ▶ croak "$_ is required" unless defined $fields->{ $_ }
Branch: 1 branch
BranchTrueFalseTotal
unless defined $fields->{$_} 0 48 48
13 }
14  
15 16 my $self = bless {connect_options => {}, %$fields}, $class;
16 16 $self->{ dbh } = DBI->connect($self->{ dsn }, $self->{ user }, $self->{ pass }, $self->{connect_options});
17 15 return $self;
18 }
19  
20 0 ▶sub quoter {
Subroutine quoter: not called CC=1 SCAR=6.9
Pod undocumented
21 0 my $self = shift;
22 0 $self->{ dbh }->get_info(29);
23 }
24  
25 0 ▶sub namesep {
Subroutine namesep: not called CC=1 SCAR=6.9
Pod undocumented
26 0 my $self = shift;
27 0 $self->{ dbh }->get_info(41);
28 }
29  
30 64 ▶sub table_columns {
Subroutine table_columns: called CC=1 SCAR=0.0
Pod undocumented
31 64 my ($self, $table) = @_;
32 64 my $sth = $self->{ dbh }->prepare("select * from $table where 1 = 0");
33 64 $sth->execute;
34 64 my $retval = \@{$sth->{NAME_lc}};
35 64 $sth->finish;
36 64 return $retval;
37 }
38  
39 69 ▶sub table_pk {
Subroutine table_pk: called CC=3 SCAR=11.0
Pod undocumented
40 69 my ($self, $table) = @_;
41 69 my @keys = $self->{ dbh }->primary_key(undef, undef, $table);
42 69 ▶ if ( @keys ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@keys) 36 33 69
43 36 @keys = map { lc($_) } @keys;
44 36 ▶ return $#keys ? \@keys : $keys[0];
Branch: 1 branch
BranchTrueFalseTotal
$#keys ? : 12 24 36
45 }
46 33 return [];
47 }
48  
49 15 1;
« Loader/DBI/SQLite.pm ↑ Summary