line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::DBChanges::Role::DBI; |
2
|
1
|
|
|
1
|
|
8039
|
use Moo::Role; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
5
|
|
3
|
1
|
|
|
1
|
|
313
|
use Types::Standard qw(HasMethods); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
8
|
|
4
|
1
|
|
|
1
|
|
517
|
use namespace::autoclean; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
5
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '1.0.1'; # 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__ |