Storage/DBI/Pg.pm

filter: Statementstmt 43.1% 19 / 44 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 53.8% 7 / 13 Podpod 100% 6 / 6 totaltotal 49.2% 32 / 65 CC 2 SCAR 7.3
CC
2
Cov
41%
next_id
6.0
connect
2.0
test_setup
2.0
CRAP 2.1
« Storage/Memory.pm ↑ Summary Storage.pm »
1 1 ▶use 5.008;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 package Data::Storage::DBI::Pg;
6 1 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 $Data::Storage::DBI::Pg::VERSION = '1.102720';
8 }
9  
10 # ABSTRACT: Base class for Pg DBI storages
11 1 ▶use Error::Hierarchy::Util 'assert_defined';
Subroutine BEGIN: called CC=1 SCAR=0.0
12 1 ▶use parent qw(Data::Storage::DBI Class::Accessor::Complex);
Subroutine BEGIN: called CC=1 SCAR=0.0
13 1 ▶use constant connect_string_dbi_id => 'Pg';
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 0 ▶sub connect {
Subroutine connect: not called CC=1 SCAR=6.9
Pod documented
16 0 my $self = shift;
17 0 $self->SUPER::connect(@_);
18  
19 # FIXME: is this the right place and the right way for setting utf-8 encoding?
20 0 $self->dbh->{pg_enable_utf8} = 1;
21 }
22  
23 0 ▶sub test_setup {
Subroutine test_setup: not called CC=1 SCAR=6.9
Pod documented
24 0 my $self = shift;
25 0 $self->connect;
26 0 $self->disconnect;
27 }
28  
29 0 ▶sub last_id {
Subroutine last_id: not called CC=1 SCAR=6.9
Pod documented
30 0 my ($self, $sequence_name) = @_;
31 0 $self->dbh->last_insert_id(undef, undef, undef, undef,
32 { sequence => $sequence_name });
33 }
34  
35 0 ▶sub next_id {
Subroutine next_id: not called CC=2 SCAR=17.9
Pod documented
36 0 my ($self, $sequence_name) = @_;
37 0 ▶ unless ($sequence_name) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($sequence_name) 0 0 0
38 0 throw Error::Hierarchy::Internal::ValueUndefined;
39 }
40 0 my $sth = $self->prepare("
41 SELECT NEXTVAL('$sequence_name')");
42 0 $sth->execute;
43 0 my ($next_id) = $sth->fetchrow_array;
44 0 $sth->finish;
45 0 $next_id;
46 }
47  
48 0 ▶sub trace {
Subroutine trace: not called CC=1 SCAR=6.9
Pod documented
49 0 my $self = shift;
50 0 $self->dbh->trace(@_);
51 }
52  
53 # Database type-specifc rewrites
54 0 ▶sub rewrite_query_for_dbd {
Subroutine rewrite_query_for_dbd: not called CC=1 SCAR=6.9
Pod documented
55 0 my ($self, $query) = @_;
56 0 $query =~ s/<USER>/CURRENT_USER/g;
57 0 $query =~ s/<NOW>/NOW()/g;
58 0 $query =~ s/<NEXTVAL>\((.*?)\)/NEXTVAL('$1')/g;
59 0 $query =~ s/<BOOL>\((.*?)\)/sprintf "CASE %s WHEN '%s' THEN 1 WHEN '%s' THEN 0 END", $1,
60 $self->delegate->YES, $self->delegate->NO
61 /eg;
62 0 $query;
63 }
64 1 1;
65  
66  
67 __END__
« Storage/Memory.pm ↑ Summary Storage.pm »