| 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
| |||||||||||||||
| 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
| |||||||||||||||
| 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__ | ||||||||||||||