MSSQL/Adapter.pm

filter: Statementstmt 100% 23 / 23 Branchbran 100% 6 / 6 Conditioncond 71.4% 5 / 7 MC/DCmcdc 50.0% 2 / 4 Subroutinesub 100% 5 / 5 Podpod 100% 1 / 1 totaltotal 91.3% 42 / 46 CC 7 SCAR 15.8
CC
7
Cov
94%
to_native
7.0
BEGIN
1.0
BEGIN
1.0
CRAP 4.8
« MSSQL/Diff/Table.pm ↑ Summary MSSQL/Introspect/Tables.pm »
1 package DBIO::MSSQL::Adapter;
2 # ABSTRACT: MSSQL base->native type resolver
3  
4 66 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 66 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 66 our $VERSION = '0.900007';
8  
9 66 ▶use Carp qw/croak/;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 66 ▶use base 'DBIO::Adapter::Base';
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 # Native MSSQL type for each portable base type. Mirrors the sibling
13 # drivers (DBIO::MySQL::Adapter, DBIO::PostgreSQL::Adapter): the eight
14 # base types are the single source of truth, resolved here.
15 #
16 # - integer promotes to bigint, as in MySQL/PostgreSQL.
17 # - text/blob use the unbounded (max) variants; the legacy `text`/`image`
18 # types are deprecated in modern MSSQL.
19 # - timestamp maps to `datetime` (not datetime2) to stay aligned with
20 # DBIO::MSSQL::Storage::DateTime::Format, whose %3N pattern is the
21 # datetime millisecond format.
22 66 my %NATIVE = (
23 integer => 'bigint',
24 text => 'nvarchar(max)',
25 boolean => 'bit',
26 double => 'float',
27 blob => 'varbinary(max)',
28 timestamp => 'datetime',
29 );
30  
31 663 ▶sub to_native {
Subroutine to_native: called CC=7 SCAR=19.5
Pod documented
32 663 my ($self, $col) = @_;
33 663 my $b = $col->{base_type};
34 663 ▶ return 'nchar(' . ($col->{size} // 255) . ')' if $b eq 'char';
Branch: 1 branch
BranchTrueFalseTotal
if $b eq "char" 20 643 663
Condition100%2/2
$col->{"size"} // 255
l!l
155
MC/DC100%1/1
$col->{"size"} // 255
$col->{"size"}
Truth table100%2/2
A
A= $col->{"size"}
Aresult
11
00
35 643 ▶ if ($b eq 'numeric') {
Branch: 1 branch
BranchTrueFalseTotal
if ($b eq "numeric") 8 635 643
36 8 my ($p, $s) = @{$col}{qw/precision scale/};
37 8 ▶ return (defined $p && defined $s) ? "numeric($p,$s)" : 'numeric';
Branch: 1 branch
BranchTrueFalseTotal
defined $p && defined $s ? : 5 3 8
Condition66%2/3
defined $p and defined $s
!ll&&!rl&&r
305
MC/DC50%1/2
defined $p and defined $s
defined $p defined $s
Truth table66%2/3
A and B
A= defined $pB= defined $s
ABresult
0X0
100
111
38 }
39 635 ▶ return $NATIVE{$b} // croak "no MSSQL native type for base '$b'";
Condition50%1/2
$NATIVE{$b} // croak("no MSSQL native type for base '${b}'")
l!l
6350
MC/DC0%0/1
$NATIVE{$b} // croak("no MSSQL native type for base '${b}'")
$NATIVE{$b}
Truth table50%1/2
A
A= $NATIVE{$b}
Aresult
11
00
40 }
41  
42 # capabilities inherited from DBIO::Adapter::Base: supports_alter_column_type => 1
43  
44 66 1;
45  
46 __END__
« MSSQL/Diff/Table.pm ↑ Summary MSSQL/Introspect/Tables.pm »