line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::DBChanges::Role::DBIC; |
2
|
1
|
|
|
1
|
|
9877
|
use Moo::Role; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
6
|
|
3
|
1
|
|
|
1
|
|
437
|
use Types::Standard qw(HasMethods); |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
19
|
|
4
|
1
|
|
|
1
|
|
696
|
use namespace::autoclean; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
10
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '1.0.2'; # VERSION |
7
|
|
|
|
|
|
|
# ABSTRACT: adapt DBChanges to DBIC |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
has schema => ( is => 'ro', required => 1, isa => HasMethods[qw(storage resultset)] ); |
11
|
0
|
|
|
0
|
|
|
sub _storage { shift->schema->storage } |
12
|
|
|
|
|
|
|
sub _db_do { |
13
|
0
|
|
|
0
|
|
|
my ($self,$sql,@args) = @_; |
14
|
|
|
|
|
|
|
$self->_storage->dbh_do( |
15
|
|
|
|
|
|
|
sub { |
16
|
0
|
|
|
0
|
|
|
my (undef,$dbh) = @_; |
17
|
|
|
|
|
|
|
# silence "NOTICE: the relation already exists" |
18
|
0
|
|
|
|
|
|
local $dbh->{PrintWarn} = 0; |
19
|
0
|
|
|
|
|
|
$dbh->do($sql,{},@args); |
20
|
|
|
|
|
|
|
} |
21
|
0
|
|
|
|
|
|
); |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub _db_fetch { |
25
|
0
|
|
|
0
|
|
|
my ($self,$sql,@args) = @_; |
26
|
|
|
|
|
|
|
return $self->_storage->dbh_do( |
27
|
|
|
|
|
|
|
sub { |
28
|
0
|
|
|
0
|
|
|
my (undef,$dbh) = @_; |
29
|
0
|
|
|
|
|
|
return $dbh->selectall_arrayref($sql, { Slice => {} }, @args); |
30
|
|
|
|
|
|
|
} |
31
|
0
|
|
|
|
|
|
); |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub _table_and_factory_for_source { |
35
|
0
|
|
|
0
|
|
|
my ($self, $source_name) = @_; |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
# source names are resultset names, and we inflate the result of |
38
|
|
|
|
|
|
|
# _db_fetch into row objects |
39
|
|
|
|
|
|
|
|
40
|
0
|
|
|
|
|
|
my $rs = $self->schema->resultset($source_name); |
41
|
0
|
|
|
|
|
|
my $table_name = $rs->result_source->name; |
42
|
|
|
|
|
|
|
|
43
|
0
|
|
|
0
|
|
|
return ($table_name, sub { $rs->new_result(shift) } ); |
|
0
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
1; |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
__END__ |