blib/lib/DBIO/PostgreSQL/Adapter.pm

filter: Statementstmt 100% 27 / 27 Branchbran 100% 8 / 8 Conditioncond 75.0% 3 / 4 MC/DCmcdc 50.0% 1 / 2 Subroutinesub 100% 6 / 6 Podpod 100% 1 / 1 totaltotal 95.8% 46 / 48 CC 7 SCAR 15.0
CC
7
Cov
97%
to_native
7.0
BEGIN
1.0
BEGIN
1.0
CRAP 4.5
« blib/lib/DBIO/PostgreSQL/Diff/SequenceOwner.pm ↑ Summary blib/lib/DBIO/PostgreSQL/InflateColumn/TSVector.pm »
1 package DBIO::PostgreSQL::Adapter;
2 # ABSTRACT: PostgreSQL base->native type resolver
3  
4 128 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 128 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 128 our $VERSION = '0.900007';
8  
9 128 ▶use Carp qw/croak/;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 128 ▶use base 'DBIO::Adapter::Base';
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 128 ▶use DBIO::PostgreSQL::Util qw(type_takes_modifier type_with_modifier);
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14  
15 128 my %NATIVE = (
16 integer => 'bigint',
17 text => 'text',
18 boolean => 'boolean',
19 double => 'double precision',
20 blob => 'bytea',
21 timestamp => 'timestamptz',
22 );
23  
24  
25 517 ▶sub to_native {
Subroutine to_native: called CC=7 SCAR=19.5
Pod documented
26 517 my ($self, $col, $context) = @_;
27 517 my $b = $col->{base_type};
28 517 ▶ return type_with_modifier('character', $col->{size} // 255, $context) if $b eq 'char';
Branch: 1 branch
BranchTrueFalseTotal
if $b eq "char" 7 510 517
Condition50%1/2
$col->{"size"} // 255
l!l
70
MC/DC0%0/1
$col->{"size"} // 255
$col->{"size"}
Truth table50%1/2
A
A= $col->{"size"}
Aresult
11
00
29 510 ▶ if ($b eq 'numeric') {
Branch: 1 branch
BranchTrueFalseTotal
if ($b eq "numeric") 14 496 510
30 14 my ($p, $s) = @{$col}{qw/precision scale/};
31 14 ▶ return type_with_modifier('numeric', defined $p ? [ $p, $s ] : undef, $context);
Branch: 1 branch
BranchTrueFalseTotal
defined $p ? : 9 5 14
32 }
33 496 ▶ my $native = $NATIVE{$b} // croak "no PostgreSQL native type for base '$b'";
Condition100%2/2
$NATIVE{$b} // croak("no PostgreSQL native type for base '${b}'")
l!l
4951
MC/DC100%1/1
$NATIVE{$b} // croak("no PostgreSQL native type for base '${b}'")
$NATIVE{$b}
Truth table100%2/2
A
A= $NATIVE{$b}
Aresult
11
00
34 return type_takes_modifier($native)
35 495 ▶ ? type_with_modifier($native, $col->{size}, $context)
Branch: 1 branch
BranchTrueFalseTotal
type_takes_modifier($native) ? : 9 486 495
36 : $native;
37 }
38  
39 # capabilities inherited from DBIO::Adapter::Base: supports_alter_column_type => 1
40  
41 128 1;
42  
43 __END__
« blib/lib/DBIO/PostgreSQL/Diff/SequenceOwner.pm ↑ Summary blib/lib/DBIO/PostgreSQL/InflateColumn/TSVector.pm »