File Coverage

blib/lib/Test/DBChanges/Role/DBI.pm
Criterion Covered Total %
statement 9 18 50.0
branch n/a
condition n/a
subroutine 3 7 42.8
pod n/a
total 12 25 48.0


line stmt bran cond sub pod time code
1             package Test::DBChanges::Role::DBI;
2 1     1   9625 use Moo::Role;
  1         3  
  1         5  
3 1     1   390 use Types::Standard qw(HasMethods);
  1         3  
  1         10  
4 1     1   622 use namespace::autoclean;
  1         2  
  1         8  
5              
6             our $VERSION = '1.0.2'; # VERSION
7             # ABSTRACT: adapt DBChanges to DBI
8              
9              
10             has dbh => ( is => 'ro', required => 1, isa => HasMethods[qw(do selectall_arrayref)] );
11              
12             sub _db_do {
13 0     0     my ($self,$sql,@args) = @_;
14 0           my $dbh = $self->dbh;
15             # silence "NOTICE: the relation already exists"
16 0           local $dbh->{PrintWarn} = 0;
17 0           $dbh->do($sql,{},@args);
18             }
19              
20             sub _db_fetch {
21 0     0     my ($self,$sql,@args) = @_;
22 0           return $self->dbh->selectall_arrayref($sql, { Slice => {} }, @args);
23             }
24              
25             sub _table_and_factory_for_source {
26 0     0     my ($self,$source_name) = @_;
27              
28             # source names are table names, and we don't transform the result
29             # of _db_fetch
30 0     0     return ( $source_name, sub { return @_ } );
  0            
31             }
32              
33             1;
34              
35             __END__