MSSQL/Adapter.pm

filter: Statementstmt 63.6% 14 / 22 Branchbran 0.0% 0 / 6 Conditioncond 0.0% 0 / 8 MC/DCmcdc 0.0% 0 / 5 Subroutinesub 80.0% 4 / 5 Podpod 0.0% 0 / 1 totaltotal 38.3% 18 / 47 CC 7 SCAR 35.8
CC
7
Cov
39%
to_native
56.0
BEGIN
1.0
BEGIN
1.0
CRAP 36.0
« MSSQL/Introspect/Indexes.pm ↑ Summary MSSQL/Introspect/Tables.pm »
1 package DBIO::MSSQL::Adapter;
2 # ABSTRACT: MSSQL base->native type resolver
3  
4 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 3 ▶use Carp qw/croak/;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 3 ▶use base 'DBIO::Adapter::Base';
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 # Native MSSQL type for each portable base type. Mirrors the sibling
10 # drivers (DBIO::MySQL::Adapter, DBIO::PostgreSQL::Adapter): the eight
11 # base types are the single source of truth, resolved here.
12 #
13 # - integer promotes to bigint, as in MySQL/PostgreSQL.
14 # - text/blob use the unbounded (max) variants; the legacy `text`/`image`
15 # types are deprecated in modern MSSQL.
16 # - timestamp maps to `datetime` (not datetime2) to stay aligned with
17 # DBIO::MSSQL::Storage::DateTime::Format, whose %3N pattern is the
18 # datetime millisecond format.
19 3 my %NATIVE = (
20 integer => 'bigint',
21 text => 'nvarchar(max)',
22 boolean => 'bit',
23 double => 'float',
24 blob => 'varbinary(max)',
25 timestamp => 'datetime',
26 );
27  
28 0 ▶sub to_native {
Subroutine to_native: not called CC=7 SCAR=40.3
Pod undocumented
29 0 my ($self, $col) = @_;
30 0 my $b = $col->{base_type};
31 0 ▶ return 'nchar(' . ($col->{size} // 255) . ')' if $b eq 'char';
Branch: 1 branch
BranchTrueFalseTotal
if $b eq "char" 0 0 0
Condition0%0/2
$col->{"size"} // 255
l!l
00
MC/DC0%0/1
$col->{"size"} // 255
$col->{"size"}
Truth table0%0/2
A
A= $col->{"size"}
Aresult
11
00
32 0 ▶ if ($b eq 'numeric') {
Branch: 1 branch
BranchTrueFalseTotal
if ($b eq "numeric") 0 0 0
33 0 my ($p, $s) = @{$col}{qw/precision scale/};
34 0 ▶ return (defined $p && defined $s) ? "numeric($p,$s)" : 'numeric';
Branch: 1 branch
BranchTrueFalseTotal
defined $p && defined $s ? : 0 0 0
Condition0%0/3
defined $p and defined $s
!ll&&!rl&&r
000
MC/DC0%0/2
defined $p and defined $s
defined $p defined $s
Truth table0%0/3
A and B
A= defined $pB= defined $s
ABresult
0X0
100
111
35 }
36 0 ▶ return $NATIVE{$b} // croak "no MSSQL native type for base '$b'";
Condition0%0/3
$NATIVE{$b} // croak("no MSSQL native type for base '${b}'")
l!l&&r!l&&!r
000
MC/DC0%0/2
$NATIVE{$b} // croak("no MSSQL native type for base '${b}'")
$NATIVE{$b} croak("no MSSQL native type for base '${b}'")
Truth table0%0/3
A // B
A= $NATIVE{$b}B= croak("no MSSQL native type for base '${b}'")
ABresult
1X1
011
000
37 }
38  
39 # capabilities inherited from DBIO::Adapter::Base: supports_alter_column_type => 1
40  
41 3 1;
42  
43 __END__
44  
45 =pod
46  
47 =encoding UTF-8
48  
49 =head1 NAME
50  
51 DBIO::MSSQL::Adapter - MSSQL base->native type resolver
52  
53 =head1 VERSION
54  
55 version 0.900001
56  
57 =head1 AUTHOR
58  
59 DBIO & DBIx::Class Authors
60  
61 =head1 COPYRIGHT AND LICENSE
62  
63 Copyright (C) 2026 DBIO Authors
64 Portions Copyright (C) 2005-2025 DBIx::Class Authors
65 Based on DBIx::Class, heavily modified.
66  
67 This is free software; you can redistribute it and/or modify it under
68 the same terms as the Perl 5 programming language system itself.
69  
70 =cut
« MSSQL/Introspect/Indexes.pm ↑ Summary MSSQL/Introspect/Tables.pm »