GraphQL/ScalarMap.pm

filter: Statementstmt 100% 23 / 23 Branchbran 100% 8 / 8 Conditioncond 100% 2 / 2 MC/DCmcdc 100% 1 / 1 Subroutinesub 100% 5 / 5 Podpod 0.0% 0 / 1 totaltotal 97.5% 39 / 40 CC 6 SCAR 13.9
CC
6
Cov
100%
for_column
6.0
BEGIN
1.0
BEGIN
1.0
CRAP 4.0
« GraphQL/Error.pm ↑ Summary GraphQL/Filter/Null.pm »
1 package DBIO::GraphQL::ScalarMap;
2 # ABSTRACT: Map DBIO column data_types to GraphQL scalars
3 15 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 15 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 15 our $VERSION = '0.900007';
7  
8 15 ▶use GraphQL::Type::Scalar qw($Int $String $Float $Boolean);
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 15 ▶use Exporter 'import';
Subroutine BEGIN: called CC=1 SCAR=0.0
11 15 our @EXPORT_OK = qw( for_column );
12  
13 # Resolution order matters:
14 # 1. Boolean: must come before Int because tinyint(1) is the MySQL idiom
15 # 2. String : bigint/bigserial/decimal/numeric/money; GraphQL Int is 32-bit
16 # signed and Float a double, so these would lose values
17 # 3. Float : float/double/real
18 # 4. Int : the 32-bit integer family
19 # 5. String : safe fallback for anything unrecognised
20 2043 ▶sub for_column {
Subroutine for_column: called CC=6 SCAR=17.9
Pod undocumented
21 2043 my ($source, $col) = @_;
22 2043 my $info = $source->column_info($col);
23 2043 ▶ my $data_type = $info->{data_type} // '';
Condition100%2/2
$info->{"data_type"} // ""
l!l
20421
MC/DC100%1/1
$info->{"data_type"} // ""
$info->{"data_type"}
Truth table100%2/2
A
A= $info->{"data_type"}
Aresult
11
00
24  
25 2043 ▶ return $Boolean if $data_type =~ /(?:\b(?:bool(?:ean)?)|tinyint\(1\))(?=\s|\z)/i;
Branch: 1 branch
BranchTrueFalseTotal
if $data_type =~ /(?:\b(?:bool(?:ean)?)|tinyint\(1\))(?=\s|\z)/i 189 1854 2043
26 1854 ▶ return $String if $data_type =~ /\b(?:bigint|bigserial|money|decimal|numeric)\b/i;
Branch: 1 branch
BranchTrueFalseTotal
if $data_type =~ /\b(?:bigint|bigserial|money|decimal|numeric)\b/i 106 1748 1854
27 1748 ▶ return $Float if $data_type =~ /\b(?:float|double(?:\s+precision)?|real)\b/i;
Branch: 1 branch
BranchTrueFalseTotal
if $data_type =~ /\b(?:float|double(?:\s+precision)?|real)\b/i 104 1644 1748
28 1644 ▶ return $Int if $data_type =~ /\b(?:int(?:eger)?|smallint|tinyint|mediumint|serial)\b/i;
Branch: 1 branch
BranchTrueFalseTotal
if $data_type =~ /\b(?:int(?:eger)?|smallint|tinyint|mediumint|serial)\b/i 1011 633 1644
29 633 return $String;
30 }
31  
32 15 1;
33  
34 __END__
« GraphQL/Error.pm ↑ Summary GraphQL/Filter/Null.pm »