Guess/Role/SQL/Pg.pm

filter: Statementstmt 100% 11 / 11 Branchbran 83.3% 10 / 12 Conditioncond 66.6% 2 / 3 MC/DCmcdc 50.0% 1 / 2 Subroutinesub 100% 2 / 2 Podpod 0.0% 0 / 1 totaltotal 83.8% 26 / 31 CC 8 SCAR 20.0
CC
8
Cov
88%
to_sql
8.2
BEGIN
1.0
CRAP 7.4
↑ Summary Guess/Role/SQL/SQLite.pm »
1 package Type::Guess::Role::SQL::Pg;
2  
3 1 ▶use Moo::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 13 ▶sub to_sql {
Subroutine to_sql: called CC=8 SCAR=21.0
Pod undocumented
6 13 my $self = shift;
7 13 ▶ my $type = ref $self->type ? $self->type->name : $self->type;
Branch: 1 branch
BranchTrueFalseTotal
ref $self->type ? : 0 13 13
8  
9 13 ▶ return $self->integer_chars > 9 ? "BIGINT" : "INTEGER" if $type eq "Int";
Branch: 2 branches
BranchTrueFalseTotal
if $type eq "Int" 4 9 13
$self->integer_chars > 9 ? : 1 3 4
10 9 ▶ return "TIMESTAMP" if $self->type eq 'DateTime';
Branch: 1 branch
BranchTrueFalseTotal
if $self->type eq "DateTime" 0 9 9
11 9 ▶ return sprintf "DECIMAL(%d,%d)", $self->length, $self->precision if $type eq "Num";
Branch: 1 branch
BranchTrueFalseTotal
if $type eq "Num" 4 5 9
12 5 ▶ return sprintf "VARCHAR(%d)", $self->length if $type eq "Str" && $self->length < 1024;
Branch: 1 branch
BranchTrueFalseTotal
if $type eq "Str" and $self->length < 1024 4 1 5
Condition66%2/3
$type eq "Str" and $self->length < 1024
!ll&&!rl&&r
014
MC/DC50%1/2
$type eq "Str" and $self->length < 1024
$type eq "Str" $self->length < 1024
Truth table66%2/3
A and B
A= $type eq "Str"B= $self->length < 1024
ABresult
0X0
100
111
13 1 return "TEXT";
14 }
15  
16 1 1;
17  
18  
19 =head2 TIMESTAMP
20  
21 Postgres distinguishes TIMESTAMP (no timezone) and TIMESTAMP WITH TIME ZONE.
22 Type::Guess emits TIMESTAMP by default. If your application is timezone-aware,
23 cast manually or compose a role that overrides to_sql for DateTime to return
24 TIMESTAMP WITH TIME ZONE.
25  
26 =cut
27  
↑ Summary Guess/Role/SQL/SQLite.pm »