Backend/PostgreSQL.pm

filter: Statementstmt 50.0% 20 / 40 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 33.3% 5 / 15 Podpod n/a totaltotal 43.8% 25 / 57 CC 2 SCAR 7.8
CC
2
Cov
48%
_munge_guid
6.0
_build_dsn
2.0
_build_db_user
2.0
CRAP 2.2
« Archive/SQLite/Sharded.pm ↑ Summary Backend/SQLite.pm »
1 3 ▶use 5.008001;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 package Metabase::Backend::PostgreSQL;
6 # ABSTRACT: Metabase backend implemented using PostgreSQL
7  
8 3 our $VERSION = '1.001';
9  
10 3 ▶use Moose::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 3 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 3 with 'Metabase::Backend::SQL';
14  
15 3 has db_name => (
16 is => 'ro',
17 isa => 'Str',
18 required => 1,
19 );
20  
21 0 ▶sub _build_dsn {
Subroutine _build_dsn: not called CC=1 SCAR=6.9
22 0 my $self = shift;
23 0 return "dbi:Pg:dbname=" . $self->db_name;
24 }
25  
26 0 ▶sub _build_db_user { return "" }
Subroutine _build_db_user: not called CC=1 SCAR=6.9
27  
28 0 ▶sub _build_db_pass { return "" }
Subroutine _build_db_pass: not called CC=1 SCAR=6.9
29  
30 0 ▶sub _build_db_type { return "PostgreSQL" }
Subroutine _build_db_type: not called CC=1 SCAR=6.9
31  
32 0 ▶sub _fixup_sql_diff {
Subroutine _fixup_sql_diff: not called CC=1 SCAR=6.9
33 0 my ($self, $diff) = @_;
34 # Strip DROP INDEX
35 0 $diff =~ s/DROP INDEX .*;//mg;
36 # Strip ALTER TABLES constraint drops
37 0 $diff =~ s/ALTER TABLE \S+ ADD CONSTRAINT.*;//mg;
38 0 return $diff;
39 }
40  
41 0 ▶around _build_dbis => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
42 0 my $orig = shift;
43 0 my $self = shift;
44 0 my $dbis = $self->$orig;
45 0 $dbis->abstract = SQL::Abstract->new(
46 quote_char => q{"},
47 );
48 0 return $dbis;
49 3 };
50  
51 0 ▶sub _build__blob_field_params {
Subroutine _build__blob_field_params: not called CC=1 SCAR=6.9
52 return {
53 0 data_type => 'text'
54 };
55 }
56  
57 0 ▶sub _build__guid_field_params {
Subroutine _build__guid_field_params: not called CC=1 SCAR=6.9
58 return {
59 0 data_type => 'uuid'
60 }
61 }
62  
63 3 my $hex = qr/[0-9a-f]/i;
64 0 ▶sub _munge_guid {
Subroutine _munge_guid: not called CC=2 SCAR=17.9
65 0 my ($self, $guid) = @_;
66 0 ▶ $guid = "00000000-0000-0000-0000-000000000000"
Branch: 1 branch
BranchTrueFalseTotal
unless $guid =~ /${hex}{8}-${hex}{4}-${hex}{4}-${hex}{4}-${hex}{12}/ 0 0 0
67 unless $guid =~ /${hex}{8}-${hex}{4}-${hex}{4}-${hex}{4}-${hex}{12}/;
68 0 return $guid;
69 }
70  
71 0 ▶sub _unmunge_guid { lc return $_[1] }
Subroutine _unmunge_guid: not called CC=1 SCAR=6.9
72  
73 3 1;
74  
75  
76 # vim: ts=2 sts=2 sw=2 et:
77  
78 __END__
« Archive/SQLite/Sharded.pm ↑ Summary Backend/SQLite.pm »