Database/Driver/Pg.pm

filter: Statementstmt 26.0% 12 / 46 Branchbran 0.0% 0 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 33.3% 4 / 12 Podpod 100% 6 / 6 totaltotal 30.5% 22 / 72 CC 5 SCAR 13.2
CC
5
Cov
22%
create_database
6.0
create_database
6.0
drop_database
6.0
CRAP 3.8
« Database/Driver.pm ↑ Summary Database/Driver/mysql.pm »
1 package Test::Database::Driver::Pg;
2 $Test::Database::Driver::Pg::VERSION = '1.113';
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 1 ▶use Test::Database::Driver;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 our @ISA = qw( Test::Database::Driver );
9  
10 0 ▶sub _version {
Subroutine _version: not called CC=1 SCAR=6.9
11 0 ▶ DBI->connect_cached( $_[0]->connection_info() )
Subroutine _version: not called CC=1 SCAR=6.9
12 ->selectcol_arrayref('SELECT VERSION()')->[0] =~ /^PostgreSQL (\S+)/;
13 0 return $1;
14 }
15  
16 0 ▶sub create_database {
Subroutine create_database: not called CC=2 SCAR=17.9
Pod documented
17 0 ▶ my ($self) = @_;
Subroutine create_database: not called CC=2 SCAR=17.9
Pod documented
18 0 my $dbname = $self->available_dbname();
19  
20 DBI->connect_cached( $self->connection_info() )
21 ->do( "CREATE DATABASE $dbname"
22 0 ▶ . ( $self->{template} ? " TEMPLATE $self->{template}" : '' ) );
Branch: 2 branches
BranchTrueFalseTotal
$self->{'template'} ? : 0 0 0
$self->{'template'} ? : 0 0 0
23  
24 # return the handle
25 0 return Test::Database::Handle->new(
26 dsn => $self->dsn($dbname),
27 name => $dbname,
28 username => $self->username(),
29 password => $self->password(),
30 driver => $self,
31 );
32 }
33  
34 0 ▶sub drop_database {
Subroutine drop_database: not called CC=2 SCAR=17.9
Pod documented
35 0 ▶ my ( $self, $dbname ) = @_;
Subroutine drop_database: not called CC=2 SCAR=17.9
Pod documented
36  
37 DBI->connect_cached( $self->connection_info() )
38 ->do("DROP DATABASE $dbname")
39 0 ▶ if grep { $_ eq $dbname } $self->databases();
Branch: 2 branches
BranchTrueFalseTotal
if grep {$_ eq $dbname;} $self->databases 0 0 0
if grep {$_ eq $dbname;} $self->databases 0 0 0
40 }
41  
42 0 ▶sub databases {
Subroutine databases: not called CC=1 SCAR=6.9
Pod documented
43 0 ▶ my ($self) = @_;
Subroutine databases: not called CC=1 SCAR=6.9
Pod documented
44 0 my $basename = qr/^@{[$self->_basename()]}/;
45 0 my $databases = eval {
46 0 DBI->connect_cached( $self->connection_info(), { PrintError => 0 } )
47 ->selectall_arrayref(
48 'SELECT datname FROM pg_catalog.pg_database');
49 };
50 0 return grep {/$basename/} map {@$_} @$databases;
51 }
52  
53 'Pg';
54  
55 __END__
« Database/Driver.pm ↑ Summary Database/Driver/mysql.pm »