GraphQL/ScalarMap.pm

filter: Statementstmt 100% 21 / 21 Branchbran 100% 6 / 6 Conditioncond 100% 2 / 2 MC/DCmcdc 100% 1 / 1 Subroutinesub 100% 5 / 5 Podpod 0.0% 0 / 1 totaltotal 97.2% 35 / 36 CC 5 SCAR 11.7
CC
5
Cov
100%
for_column
5.0
BEGIN
1.0
BEGIN
1.0
CRAP 3.2
« GraphQL/Mutation.pm ↑ Summary GraphQL/Filter/Null.pm »
1 package DBIO::GraphQL::ScalarMap;
2 # ABSTRACT: Map DBIO column data_types to GraphQL scalars
3 8 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 8 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 8 ▶use GraphQL::Type::Scalar qw($Int $String $Float $Boolean);
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 8 ▶use Exporter 'import';
Subroutine BEGIN: called CC=1 SCAR=0.0
9 8 our @EXPORT_OK = qw( for_column );
10  
11 # Resolution order matters:
12 # 1. Boolean: must come before Int because tinyint(1) is the MySQL idiom
13 # 2. Float : decimal/numeric before the int catch-all
14 # 3. Int : all integer family types
15 # 4. String : safe fallback for anything unrecognised
16 704 ▶sub for_column {
Subroutine for_column: called CC=5 SCAR=16.1
Pod undocumented
17 704 my ($source, $col) = @_;
18 704 my $info = $source->column_info($col);
19 704 ▶ my $data_type = $info->{data_type} // '';
Condition100%2/2
$info->{"data_type"} // ""
l!l
7031
MC/DC100%1/1
$info->{"data_type"} // ""
$info->{"data_type"}
Truth table100%2/2
A
A= $info->{"data_type"}
Aresult
11
00
20  
21 704 ▶ 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 112 592 704
22 592 ▶ return $Float if $data_type =~ /\b(?:float|double(?:\s+precision)?|real|money|decimal|numeric)\b/i;
Branch: 1 branch
BranchTrueFalseTotal
if $data_type =~ /\b(?:float|double(?:\s+precision)?|real|money|decimal|numeric)\b/i 118 474 592
23 474 ▶ return $Int if $data_type =~ /\b(?:int(?:eger)?|bigint|smallint|tinyint|mediumint|serial)\b/i;
Branch: 1 branch
BranchTrueFalseTotal
if $data_type =~ /\b(?:int(?:eger)?|bigint|smallint|tinyint|mediumint|serial)\b/i 263 211 474
24 211 return $String;
25 }
26  
27 8 1;
28  
29 __END__
30  
31 =pod
32  
33 =encoding UTF-8
34  
35 =head1 NAME
36  
37 DBIO::GraphQL::ScalarMap - Map DBIO column data_types to GraphQL scalars
38  
39 =head1 VERSION
40  
41 version 0.900001
42  
43 =head1 AUTHOR
44  
45 DBIO Authors
46  
47 =head1 COPYRIGHT AND LICENSE
48  
49 Copyright (C) 2026 DBIO Authors
50  
51 This is free software; you can redistribute it and/or modify it under
52 the same terms as the Perl 5 programming language system itself.
53  
54 =cut
« GraphQL/Mutation.pm ↑ Summary GraphQL/Filter/Null.pm »