« 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
Condition50%1/2
$col->{"size"} // 255
MC/DC0%0/1
$col->{"size"} // 255
$col->{"size"}
Truth table50%1/2
A
A= $col->{"size"}
| |||||||||||||||||||||
| 29 | 510 | ▶ | if ($b eq 'numeric') { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 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
| |||||||||||||||||||||
| 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}'")
MC/DC100%1/1
$NATIVE{$b} // croak("no PostgreSQL native type for base '${b}'")
$NATIVE{$b}
Truth table100%2/2
A
A= $NATIVE{$b}
| |||||||||||||||||||||
| 34 | return type_takes_modifier($native) | ||||||||||||||||||||
| 35 | 495 | ▶ | ? type_with_modifier($native, $col->{size}, $context) | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 36 | : $native; | ||||||||||||||||||||
| 37 | } | ||||||||||||||||||||
| 38 | |||||||||||||||||||||
| 39 | # capabilities inherited from DBIO::Adapter::Base: supports_alter_column_type => 1 | ||||||||||||||||||||
| 40 | |||||||||||||||||||||
| 41 | 128 | 1; | |||||||||||||||||||
| 42 | |||||||||||||||||||||
| 43 | __END__ | ||||||||||||||||||||