PostgreSQL/Adapter.pm

filter: Statementstmt 100% 22 / 22 Branchbran 83.3% 5 / 6 Conditioncond 50.0% 4 / 8 MC/DCmcdc 0.0% 0 / 5 Subroutinesub 100% 5 / 5 Podpod 0.0% 0 / 1 totaltotal 76.6% 36 / 47 CC 7 SCAR 16.5
CC
7
Cov
86%
to_native
7.6
BEGIN
1.0
BEGIN
1.0
CRAP 5.2
« PostgreSQL/Diff/Function.pm ↑ Summary PostgreSQL/Introspect/Parse.pm »
1 package DBIO::PostgreSQL::Adapter;
2 # ABSTRACT: PostgreSQL base->native type resolver
3  
4 9 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 9 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 9 ▶use Carp qw/croak/;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 9 ▶use base 'DBIO::Adapter::Base';
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 9 my %NATIVE = (
10 integer => 'bigint',
11 text => 'text',
12 boolean => 'boolean',
13 double => 'double precision',
14 blob => 'bytea',
15 timestamp => 'timestamptz',
16 );
17  
18 12 ▶sub to_native {
Subroutine to_native: called CC=7 SCAR=20.2
Pod undocumented
19 12 my ($self, $col) = @_;
20 12 my $b = $col->{base_type};
21 12 ▶ return 'character(' . ($col->{size} // 255) . ')' if $b eq 'char';
Branch: 1 branch
BranchTrueFalseTotal
if $b eq "char" 1 11 12
Condition50%1/2
$col->{"size"} // 255
l!l
10
MC/DC0%0/1
$col->{"size"} // 255
$col->{"size"}
Truth table50%1/2
A
A= $col->{"size"}
Aresult
11
00
22 11 ▶ if ($b eq 'numeric') {
Branch: 1 branch
BranchTrueFalseTotal
if ($b eq "numeric") 1 10 11
23 1 my ($p, $s) = @{$col}{qw/precision scale/};
24 1 ▶ return (defined $p && defined $s) ? "numeric($p,$s)" : 'numeric';
Branch: 1 branch
BranchTrueFalseTotal
defined $p && defined $s ? : 1 0 1
Condition33%1/3
defined $p and defined $s
!ll&&!rl&&r
001
MC/DC0%0/2
defined $p and defined $s
defined $p defined $s
Truth table33%1/3
A and B
A= defined $pB= defined $s
ABresult
0X0
100
111
25 }
26 10 ▶ return $NATIVE{$b} // croak "no PostgreSQL native type for base '$b'";
Condition66%2/3
$NATIVE{$b} // croak("no PostgreSQL native type for base '${b}'")
l!l&&r!l&&!r
910
MC/DC0%0/2
$NATIVE{$b} // croak("no PostgreSQL native type for base '${b}'")
$NATIVE{$b} croak("no PostgreSQL native type for base '${b}'")
Truth table33%1/3
A // B
A= $NATIVE{$b}B= croak("no PostgreSQL native type for base '${b}'")
ABresult
1X1
011
000
27 }
28  
29 # capabilities inherited from DBIO::Adapter::Base: supports_alter_column_type => 1
30  
31 9 1;
32  
33 __END__
34  
35 =pod
36  
37 =encoding UTF-8
38  
39 =head1 NAME
40  
41 DBIO::PostgreSQL::Adapter - PostgreSQL base->native type resolver
42  
43 =head1 VERSION
44  
45 version 0.900001
46  
47 =head1 AUTHOR
48  
49 DBIO & DBIx::Class Authors
50  
51 =head1 COPYRIGHT AND LICENSE
52  
53 Copyright (C) 2026 DBIO Authors
54 Portions Copyright (C) 2005-2025 DBIx::Class Authors
55 Based on DBIx::Class, heavily modified.
56  
57 This is free software; you can redistribute it and/or modify it under
58 the same terms as the Perl 5 programming language system itself.
59  
60 =cut
« PostgreSQL/Diff/Function.pm ↑ Summary PostgreSQL/Introspect/Parse.pm »