Oracle/Type.pm

filter: Statementstmt 95.0% 95 / 100 Branchbran 88.2% 113 / 128 Conditioncond 80.4% 78 / 97 MC/DCmcdc 66.0% 35 / 53 Subroutinesub 90.9% 10 / 11 Podpod 100% 7 / 7 totaltotal 85.3% 338 / 396 CC 97 SCAR 35.8
CC
97
Cov
88%
map_dbio_type_to_oracle
48.6
map_dbd_type_to_dbio
39.7
__ANON__
7.0
CRAP 35.8
« Oracle/DDL.pm ↑ Summary Oracle/Introspect/ForeignKeys.pm »
1 package DBIO::Oracle::Type;
2 # ABSTRACT: Oracle type mapping utilities
3  
4 58 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 58 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 58 ▶use DBIO::Exception ();
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 58 our $VERSION = '0.900007';
10  
11  
12  
13 48 ▶sub is_lob_type {
Subroutine is_lob_type: called CC=3 SCAR=11.8
Pod documented
14 48 my ($self, $dt) = @_;
15 48 ▶ $dt && ($dt =~ /lob|bfile|text|image|bytea|memo/i
Branch: 1 branch
BranchTrueFalseTotal
$dt and $dt =~ /lob|bfile|text|image|bytea|memo/i || $dt =~ /^long(?:\s+(?:raw|bit\s*varying|varbit|binary |varchar|character\s*varying|nvarchar |national\s*character\s*varying))?\z/xi 48 0 48
Condition66%4/6
$dt && ($dt =~ /lob|bfile|text|image|bytea|memo/i || $dt =~ /^long(?:\s+(?:raw|bit\s*varying|varbit|binary |varchar|character\s*varying|nvarchar |national\s*character\s*varying))?\z/xi)
!ll&&!rl&&r
02325
$dt =~ /lob|bfile|text|image|bytea|memo/i or $dt =~ /^long(?:\s+(?:raw|bit\s*varying|varbit|binary |varchar|character\s*varying|nvarchar |national\s*character\s*varying))?\z/xi
l!l&&r!l&&!r
25023
MC/DC33%1/3
$dt && ($dt =~ /lob|bfile|text|image|bytea|memo/i || $dt =~ /^long(?:\s+(?:raw|bit\s*varying|varbit|binary |varchar|character\s*varying|nvarchar |national\s*character\s*varying))?\z/xi)
$dt $dt =~ /lob|bfile|text|image|bytea|memo/i $dt =~ /^long(?:\s+(?:raw|bit\s*varying|varbit|binary |varchar|character\s*varying|nvarchar |national\s*character\s*varying))?\z/xi
Truth table50%2/4
A && B or C
A= $dtB= $dt =~ /lob|bfile|text|image|bytea|memo/iC= $dt =~ /^long(?:\s+(?:raw|bit\s*varying|varbit|binary |varchar|character\s*varying|nvarchar |national\s*character\s*varying))?\z/xi
ABCresult
0XX0
1000
11X1
1011
16 || $dt =~ /^long(?:\s+(?:raw|bit\s*varying|varbit|binary
17 |varchar|character\s*varying|nvarchar
18 |national\s*character\s*varying))?\z/xi);
19 }
20  
21  
22 3 ▶sub is_text_lob_type {
Subroutine is_text_lob_type: called CC=3 SCAR=11.8
Pod documented
23 3 my ($self, $dt) = @_;
24 3 ▶ $dt && ($dt =~ /^(?:n?clob|memo)\z/i
Branch: 1 branch
BranchTrueFalseTotal
$dt and $dt =~ /^(?:n?clob|memo)\z/i || $dt =~ /^long(?:\s+(?:varchar|character\s*varying|nvarchar |national\s*character\s*varying))\z/xi 3 0 3
Condition66%4/6
$dt && ($dt =~ /^(?:n?clob|memo)\z/i || $dt =~ /^long(?:\s+(?:varchar|character\s*varying|nvarchar |national\s*character\s*varying))\z/xi)
!ll&&!rl&&r
021
$dt =~ /^(?:n?clob|memo)\z/i or $dt =~ /^long(?:\s+(?:varchar|character\s*varying|nvarchar |national\s*character\s*varying))\z/xi
l!l&&r!l&&!r
102
MC/DC33%1/3
$dt && ($dt =~ /^(?:n?clob|memo)\z/i || $dt =~ /^long(?:\s+(?:varchar|character\s*varying|nvarchar |national\s*character\s*varying))\z/xi)
$dt $dt =~ /^(?:n?clob|memo)\z/i $dt =~ /^long(?:\s+(?:varchar|character\s*varying|nvarchar |national\s*character\s*varying))\z/xi
Truth table50%2/4
A && B or C
A= $dtB= $dt =~ /^(?:n?clob|memo)\z/iC= $dt =~ /^long(?:\s+(?:varchar|character\s*varying|nvarchar |national\s*character\s*varying))\z/xi
ABCresult
0XX0
1000
11X1
1011
25 || $dt =~ /^long(?:\s+(?:varchar|character\s*varying|nvarchar
26 |national\s*character\s*varying))\z/xi);
27 }
28  
29  
30 3 ▶sub oracle_lob_bind_attrs {
Subroutine oracle_lob_bind_attrs: called CC=2 SCAR=6.9
Pod documented
31 3 my ($is_text) = @_;
32 # DBD::Oracle is loaded lazily: this function only runs for real LOB binds,
33 # i.e. with a live database connection, where DBD::Oracle must be present.
34 # Loading it at compile time would make every offline user of this module
35 # (e.g. DBIO::Oracle::Diff::Column) fail on hosts without DBD::Oracle.
36 3 require DBD::Oracle;
37 return {
38 3 ▶ ora_type => $is_text ? DBD::Oracle::ORA_CLOB() : DBD::Oracle::ORA_BLOB(),
Branch: 1 branch
BranchTrueFalseTotal
$is_text ? : 1 2 3
39 };
40 }
41  
42  
43 67 ▶sub render_default_value {
Subroutine render_default_value: called CC=4 SCAR=13.9
Pod documented
44 67 my ($dv) = @_;
45 67 ▶ return undef unless defined $dv;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $dv 1 66 67
46 66 ▶ return $$dv if ref $dv eq 'SCALAR';
Branch: 1 branch
BranchTrueFalseTotal
if ref $dv eq "SCALAR" 6 60 66
47 60 ▶ return "$dv" if $dv =~ /\A(?:0|-?[1-9][0-9]*(?:\.[0-9]*[1-9])?|-?0\.[0-9]*[1-9])\z/;
Branch: 1 branch
BranchTrueFalseTotal
if $dv =~ /\A(?:0|-?[1-9][0-9]*(?:\.[0-9]*[1-9])?|-?0\.[0-9]*[1-9])\z/ 20 40 60
48 40 (my $lit = $dv) =~ s/'/''/g;
49 40 return "'$lit'";
50 }
51  
52  
53 0 ▶sub normalize_type {
Subroutine normalize_type: not called CC=2 SCAR=17.9
Pod documented
54 0 my ($t) = @_;
55 0 ▶ $t //= '';
Condition0%0/2
$t //= ""
l!l
00
MC/DC0%0/1
$t //= ""
$t
Truth table0%0/2
A
A= $t
Aresult
11
00
56 0 $t =~ s/\s+/ /g;
57 0 return uc $t;
58 }
59  
60  
61 28 ▶sub map_dbd_type_to_dbio {
Subroutine map_dbd_type_to_dbio: called CC=35 SCAR=36.8
Pod documented
62 28 my ($data_type, %args) = @_;
63 28 ▶ my $nchar_size_factor = $args{nchar_size_factor} // 1;
Condition100%2/2
$args{"nchar_size_factor"} // 1
l!l
127
MC/DC100%1/1
$args{"nchar_size_factor"} // 1
$args{"nchar_size_factor"}
Truth table100%2/2
A
A= $args{"nchar_size_factor"}
Aresult
11
00
64  
65 28 ▶ $data_type //= '';
Condition50%1/2
$data_type //= ""
l!l
280
MC/DC0%0/1
$data_type //= ""
$data_type
Truth table50%1/2
A
A= $data_type
Aresult
11
00
66 28 my $lc_dt = lc $data_type;
67  
68 28 my %col = (data_type => $lc_dt);
69  
70 28 ▶ if ($lc_dt =~ /^(?:n(?:var)?char2?|u?rowid|nclob)\z/i) {
Branch: 9 branches
BranchTrueFalseTotal
if ($lc_dt =~ /^(?:n(?:var)?char2?|u?rowid|nclob)\z/i) { } 4 24 28
elsif ($lc_dt =~ /^(?:n?[cb]lob|long(?: raw)?|bfile|date|binary_(?:float|double)|rowid)\z/i) { } 3 21 24
elsif ($lc_dt =~ /^(?:var)?char2?\z/i) { } 5 16 21
elsif ($lc_dt =~ /^(number|decimal)\z/i) { } 4 12 16
elsif (my($precision) = $lc_dt =~ /^timestamp\((\d+)\)(?: with(?: local)? time zone)?\z/i) { } 3 9 12
elsif (my($year_p) = $lc_dt =~ /^interval year\((\d+)\) to month\z/i) { } 2 7 9
elsif (() = $lc_dt =~ /^interval day\((\d+)\) to second\((\d+)\)\z/i) { } 1 6 7
elsif ($lc_dt eq 'float') { } 5 1 6
elsif ($lc_dt eq 'raw') { } 1 0 1
71 4 $col{data_type} = $data_type; # keep case for special types
72 4 ▶ $col{size} = length($data_type) if $lc_dt =~ /^u?rowid\z/i;
Branch: 1 branch
BranchTrueFalseTotal
if $lc_dt =~ /^u?rowid\z/i 0 4 4
73 # NCHAR and NVARCHAR2 carry their size. ALL_TAB_COLUMNS.data_length holds
74 # it in bytes of the national character set (NVARCHAR2(20) is 40 in
75 # AL16UTF16); char_length holds the characters, which is what was
76 # declared. Without char_length the bytes are divided by the factor.
77 4 ▶ if ($lc_dt =~ /^n(?:var)?char2?\z/i) {
Branch: 1 branch
BranchTrueFalseTotal
if ($lc_dt =~ /^n(?:var)?char2?\z/i) 4 0 4
78 $col{size} = $args{char_length}
79 ? $args{char_length}
80 4 ▶ : $args{data_length} ? $args{data_length} / $nchar_size_factor : ();
Branch: 2 branches
BranchTrueFalseTotal
$args{'char_length'} ? : 1 3 4
$args{'data_length'} ? : 3 0 3
81 4 ▶ delete $col{size} unless defined $col{size};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $col{"size"} 0 4 4
82 }
83 }
84 elsif ($lc_dt =~ /^(?:n?[cb]lob|long(?: raw)?|bfile|date|binary_(?:float|double)|rowid)\z/i) {
85 3 delete $col{size};
86 }
87 elsif ($lc_dt =~ /^(?:var)?char2?\z/i) {
88 # data_length is bytes (80 for VARCHAR2(20 CHAR) in AL32UTF8). A column
89 # of character semantics (char_used 'C') is read as "N CHAR", which
90 # map_dbio_type_to_oracle writes back as it is; BYTE keeps the plain size.
91 $col{size} = ($args{char_used} // '') eq 'C' && $args{char_length}
92 ? "$args{char_length} CHAR"
93 5 ▶ : $args{data_length};
Branch: 1 branch
BranchTrueFalseTotal
($args{'char_used'} // '') eq 'C' && $args{'char_length'} ? : 2 3 5
Condition80%4/5
($args{"char_used"} // "") eq "C" and $args{"char_length"}
!ll&&!rl&&r
302
$args{"char_used"} // ""
l!l
32
MC/DC50%1/2
($args{"char_used"} // "") eq "C" and $args{"char_length"}
$args{"char_used"} $args{"char_length"}
Truth table66%2/3
A and B
A= $args{"char_used"}B= $args{"char_length"}
ABresult
0X0
100
111
94 }
95 elsif ($lc_dt =~ /^(number|decimal)\z/i) {
96 4 $col{data_type} = 'numeric';
97 # INTEGER/SMALLINT, what integer is written as, have no precision and a
98 # scale of 0; a bare NUMBER has neither. NUMBER(38) and NUMBER(38,0)
99 # (precision 38) are numeric like any other NUMBER(p,s).
100 4 ▶ if (!defined $args{data_precision} && defined $args{data_scale}
Branch: 3 branches
BranchTrueFalseTotal
if (not defined $args{'data_precision'} and defined $args{'data_scale'} and $args{'data_scale'} == 0) { } 1 3 4
elsif (defined $args{'data_precision'} and defined $args{'data_scale'}) { } 2 1 3
elsif (defined $args{'data_precision'}) { } 0 1 1
Condition83%5/6
not defined $args{"data_precision"} and defined $args{"data_scale"} and $args{"data_scale"} == 0
!ll&&!rl&&r
301
not defined $args{"data_precision"} and defined $args{"data_scale"}
!ll&&!rl&&r
211
MC/DC66%2/3
not defined $args{"data_precision"} and defined $args{"data_scale"} and $args{"data_scale"} == 0
not defined $args{"data_precision"} defined $args{"data_scale"} $args{"data_scale"} == 0
Truth table75%3/4
not(A) and B and C
A= not defined $args{"data_precision"}B= defined $args{"data_scale"}C= $args{"data_scale"} == 0
ABCresult
0XX0
10X0
1100
1111
101 && $args{data_scale} == 0) {
102 1 $col{data_type} = 'integer';
103 }
104 ▶ elsif (defined $args{data_precision} && defined $args{data_scale}) {
Condition66%2/3
defined $args{"data_precision"} and defined $args{"data_scale"}
!ll&&!rl&&r
102
MC/DC50%1/2
defined $args{"data_precision"} and defined $args{"data_scale"}
defined $args{"data_precision"} defined $args{"data_scale"}
Truth table66%2/3
A and B
A= defined $args{"data_precision"}B= defined $args{"data_scale"}
ABresult
0X0
100
111
105 2 $col{size} = [$args{data_precision}, $args{data_scale}];
106 }
107 elsif (defined $args{data_precision}) {
108 0 $col{size} = $args{data_precision};
109 }
110 }
111 elsif (my ($precision) = $lc_dt =~ /^timestamp\((\d+)\)(?: with(?: local)? time zone)?\z/i) {
112 3 ▶ $col{data_type} = $data_type =~ /local time zone/i ? 'timestamp with local time zone'
Branch: 2 branches
BranchTrueFalseTotal
$data_type =~ /local time zone/i ? : 2 1 3
$data_type =~ /time zone/i ? : 1 0 1
113 : $data_type =~ /time zone/i ? 'timestamp with time zone'
114 : 'timestamp';
115 3 ▶ $col{size} = $precision unless $precision == 6;
Branch: 1 branch
BranchTrueFalseTotal
unless $precision == 6 2 1 3
116 }
117 elsif (my ($year_p) = $lc_dt =~ /^interval year\((\d+)\) to month\z/i) {
118 # the dictionary names the precision inside the type: INTERVAL YEAR(3) TO MONTH
119 2 $col{data_type} = 'interval year to month';
120 2 ▶ $col{size} = $year_p unless $year_p == 2;
Branch: 1 branch
BranchTrueFalseTotal
unless $year_p == 2 1 1 2
121 }
122 elsif (my ($day_p, $sec_p) = $lc_dt =~ /^interval day\((\d+)\) to second\((\d+)\)\z/i) {
123 1 $col{data_type} = 'interval day to second';
124 1 ▶ $col{size} = [$day_p, $sec_p] unless ($day_p == 2 && $sec_p == 6);
Branch: 1 branch
BranchTrueFalseTotal
unless $day_p == 2 and $sec_p == 6 1 0 1
Condition33%1/3
$day_p == 2 and $sec_p == 6
!ll&&!rl&&r
100
MC/DC0%0/2
$day_p == 2 and $sec_p == 6
$day_p == 2 $sec_p == 6
Truth table33%1/3
A and B
A= $day_p == 2B= $sec_p == 6
ABresult
0X0
100
111
125 }
126 elsif ($lc_dt eq 'float') {
127 # data_length is 22 for every FLOAT; the binary precision is in
128 # data_precision, and a FLOAT without one is FLOAT(126), which carries no
129 # size here (the dictionary cannot tell the two apart).
130 5 $col{data_type} = 'float';
131 $col{size} = $args{data_precision}
132 5 ▶ if defined $args{data_precision} && $args{data_precision} != 126;
Branch: 1 branch
BranchTrueFalseTotal
if defined $args{"data_precision"} and $args{"data_precision"} != 126 3 2 5
Condition100%3/3
defined $args{"data_precision"} and $args{"data_precision"} != 126
!ll&&!rl&&r
113
MC/DC100%2/2
defined $args{"data_precision"} and $args{"data_precision"} != 126
defined $args{"data_precision"} $args{"data_precision"} != 126
Truth table100%3/3
A and B
A= defined $args{"data_precision"}B= $args{"data_precision"} != 126
ABresult
0X0
100
111
133 }
134 elsif ($lc_dt eq 'raw') {
135 # data_length of a RAW is its length in bytes, which is what is declared
136 1 ▶ $col{size} = $args{data_length} if $args{data_length};
Branch: 1 branch
BranchTrueFalseTotal
if $args{"data_length"} 1 0 1
137 }
138  
139 28 return \%col;
140 }
141  
142  
143 1052 ▶sub map_dbio_type_to_oracle {
Subroutine map_dbio_type_to_oracle: called CC=48 SCAR=38.8
Pod documented
144 1052 my ($type, %args) = @_;
145 1052 ▶ $type //= 'varchar2';
Condition50%1/2
$type //= "varchar2"
l!l
10520
MC/DC0%0/1
$type //= "varchar2"
$type
Truth table50%1/2
A
A= $type
Aresult
11
00
146 # compared as it means: letter case and blanks (double precision) are not
147 # part of the type; $type itself is what the fallback writes
148 1052 (my $lc = lc $type) =~ s/\s+/ /g;
149 1052 $lc =~ s/\A | \z//g;
150  
151 1052 my $size = $args{size};
152  
153 # Render a base type with its optional size, e.g. VARCHAR2(128) or
154 # NUMBER(10,2). When no size is given, fall back to $default (which may
155 # itself be undef for an unsized base type).
156 642 ▶ my $sized = sub {
Subroutine __ANON__: called CC=7 SCAR=19.5
157 642 my ($base, $default) = @_;
158 my $spec = defined $size
159 642 ▶ ? (ref $size eq 'ARRAY' ? join(',', grep { defined } @$size) : $size)
Branch: 2 branches
BranchTrueFalseTotal
defined $size ? : 252 390 642
ref $size eq 'ARRAY' ? : 22 230 252
160 : $default;
161 # a length semantics is written the one way: "20 CHAR", "20 BYTE"
162 642 ▶ $spec = "$1 \U$2" if defined $spec && $spec =~ /\A\s*(\d+)\s+(char|byte)\s*\z/i;
Branch: 1 branch
BranchTrueFalseTotal
if defined $spec and $spec =~ /\A\s*(\d+)\s+(char|byte)\s*\z/i 12 630 642
Condition100%3/3
defined $spec and $spec =~ /\A\s*(\d+)\s+(char|byte)\s*\z/i
!ll&&!rl&&r
23739312
MC/DC100%2/2
defined $spec and $spec =~ /\A\s*(\d+)\s+(char|byte)\s*\z/i
defined $spec $spec =~ /\A\s*(\d+)\s+(char|byte)\s*\z/i
Truth table100%3/3
A and B
A= defined $specB= $spec =~ /\A\s*(\d+)\s+(char|byte)\s*\z/i
ABresult
0X0
100
111
163 642 ▶ return defined $spec && length $spec ? "$base($spec)" : $base;
Branch: 1 branch
BranchTrueFalseTotal
defined $spec && length $spec ? : 405 237 642
Condition66%2/3
defined $spec and length $spec
!ll&&!rl&&r
2370405
MC/DC50%1/2
defined $spec and length $spec
defined $spec length $spec
Truth table66%2/3
A and B
A= defined $specB= length $spec
ABresult
0X0
100
111
164 1052 };
165  
166 # Numeric types
167 # INTEGER, not a bare NUMBER: the dictionary reports a bare NUMBER with
168 # neither precision nor scale, which is read as numeric, and NUMBER(38) with
169 # precision 38, which is numeric(38); INTEGER is precision NULL, scale 0,
170 # which only integer is (karr k38).
171 1052 ▶ return 'INTEGER' if $lc eq 'integer' || $lc eq 'bigint' || $lc eq 'smallint';
Branch: 1 branch
BranchTrueFalseTotal
if $lc eq "integer" or $lc eq "bigint" or $lc eq "smallint" 369 683 1052
Condition100%6/6
$lc eq "integer" or $lc eq "bigint" or $lc eq "smallint"
l!l&&r!l&&!r
3681683
$lc eq "integer" or $lc eq "bigint"
l!l&&r!l&&!r
3671684
MC/DC100%3/3
$lc eq "integer" or $lc eq "bigint" or $lc eq "smallint"
$lc eq "integer" $lc eq "bigint" $lc eq "smallint"
Truth table100%4/4
A or B or C
A= $lc eq "integer"B= $lc eq "bigint"C= $lc eq "smallint"
ABCresult
1XX1
01X1
0011
0000
172 683 ▶ return 'NUMBER(10)' if $lc eq 'serial';
Branch: 1 branch
BranchTrueFalseTotal
if $lc eq "serial" 0 683 683
173 683 ▶ return 'NUMBER(20)' if $lc eq 'bigserial';
Branch: 1 branch
BranchTrueFalseTotal
if $lc eq "bigserial" 0 683 683
174  
175 # Character types
176 683 ▶ return $sized->('VARCHAR2', 255) if $lc eq 'varchar' || $lc eq 'varchar2';
Branch: 1 branch
BranchTrueFalseTotal
if $lc eq "varchar" or $lc eq "varchar2" 319 364 683
Condition100%3/3
$lc eq "varchar" or $lc eq "varchar2"
l!l&&r!l&&!r
193126364
MC/DC100%2/2
$lc eq "varchar" or $lc eq "varchar2"
$lc eq "varchar" $lc eq "varchar2"
Truth table100%3/3
A or B
A= $lc eq "varchar"B= $lc eq "varchar2"
ABresult
1X1
011
000
177 # A national type is of character semantics always; Oracle refuses
178 # NCHAR(5 CHAR), so "5 CHAR" is written as 5.
179 364 ▶ if ($lc eq 'nvarchar2' || $lc eq 'nvarchar' || $lc eq 'nchar') {
Branch: 1 branch
BranchTrueFalseTotal
if ($lc eq "nvarchar2" or $lc eq "nvarchar" or $lc eq "nchar") 26 338 364
Condition100%6/6
$lc eq "nvarchar2" or $lc eq "nvarchar" or $lc eq "nchar"
l!l&&r!l&&!r
1610338
$lc eq "nvarchar2" or $lc eq "nvarchar"
l!l&&r!l&&!r
313348
MC/DC100%3/3
$lc eq "nvarchar2" or $lc eq "nvarchar" or $lc eq "nchar"
$lc eq "nvarchar2" $lc eq "nvarchar" $lc eq "nchar"
Truth table100%4/4
A or B or C
A= $lc eq "nvarchar2"B= $lc eq "nvarchar"C= $lc eq "nchar"
ABCresult
1XX1
01X1
0011
0000
180 26 ▶ $size = $1 if defined $size && !ref $size && $size =~ /\A\s*(\d+)\s+CHAR\s*\z/i;
Branch: 1 branch
BranchTrueFalseTotal
if defined $size and not ref $size and $size =~ /\A\s*(\d+)\s+CHAR\s*\z/i 3 23 26
Condition83%5/6
defined $size and not ref $size and $size =~ /\A\s*(\d+)\s+CHAR\s*\z/i
!ll&&!rl&&r
4193
defined $size and not ref $size
!ll&&!rl&&r
4022
MC/DC66%2/3
defined $size and not ref $size and $size =~ /\A\s*(\d+)\s+CHAR\s*\z/i
defined $size not ref $size $size =~ /\A\s*(\d+)\s+CHAR\s*\z/i
Truth table75%3/4
A and not(B) and C
A= defined $sizeB= not ref $sizeC= $size =~ /\A\s*(\d+)\s+CHAR\s*\z/i
ABCresult
0XX0
10X0
1100
1111
181 26 ▶ return $sized->($lc eq 'nchar' ? ('NCHAR', 1) : ('NVARCHAR2', 255));
Branch: 1 branch
BranchTrueFalseTotal
$lc eq 'nchar' ? : 10 16 26
182 }
183 338 ▶ return $sized->('CHAR', 1) if $lc eq 'char';
Branch: 1 branch
BranchTrueFalseTotal
if $lc eq "char" 13 325 338
184 325 ▶ return 'CLOB' if $lc eq 'text' || $lc eq 'long';
Branch: 1 branch
BranchTrueFalseTotal
if $lc eq "text" or $lc eq "long" 4 321 325
Condition66%2/3
$lc eq "text" or $lc eq "long"
l!l&&r!l&&!r
40321
MC/DC50%1/2
$lc eq "text" or $lc eq "long"
$lc eq "text" $lc eq "long"
Truth table66%2/3
A or B
A= $lc eq "text"B= $lc eq "long"
ABresult
1X1
011
000
185  
186 # Date/time types
187 321 ▶ return 'DATE' if $lc eq 'date';
Branch: 1 branch
BranchTrueFalseTotal
if $lc eq "date" 8 313 321
188 313 ▶ return $sized->('TIMESTAMP') if $lc eq 'timestamp' || $lc eq 'datetime';
Branch: 1 branch
BranchTrueFalseTotal
if $lc eq "timestamp" or $lc eq "datetime" 22 291 313
Condition66%2/3
$lc eq "timestamp" or $lc eq "datetime"
l!l&&r!l&&!r
220291
MC/DC50%1/2
$lc eq "timestamp" or $lc eq "datetime"
$lc eq "timestamp" $lc eq "datetime"
Truth table66%2/3
A or B
A= $lc eq "timestamp"B= $lc eq "datetime"
ABresult
1X1
011
000
189 291 ▶ if ($lc eq 'timestamptz' || $lc eq 'timestamp with time zone') {
Branch: 1 branch
BranchTrueFalseTotal
if ($lc eq "timestamptz" or $lc eq "timestamp with time zone") 4 287 291
Condition100%3/3
$lc eq "timestamptz" or $lc eq "timestamp with time zone"
l!l&&r!l&&!r
13287
MC/DC100%2/2
$lc eq "timestamptz" or $lc eq "timestamp with time zone"
$lc eq "timestamptz" $lc eq "timestamp with time zone"
Truth table100%3/3
A or B
A= $lc eq "timestamptz"B= $lc eq "timestamp with time zone"
ABresult
1X1
011
000
190 4 my $ts = $sized->('TIMESTAMP');
191 4 return "$ts WITH TIME ZONE";
192 }
193  
194 287 ▶ if ($lc eq 'timestamp with local time zone') {
Branch: 1 branch
BranchTrueFalseTotal
if ($lc eq "timestamp with local time zone") 3 284 287
195 3 my $ts = $sized->('TIMESTAMP');
196 3 return "$ts WITH LOCAL TIME ZONE";
197 }
198  
199 # Binary types
200 284 ▶ return 'BLOB' if $lc eq 'bytea' || $lc eq 'blob';
Branch: 1 branch
BranchTrueFalseTotal
if $lc eq "bytea" or $lc eq "blob" 2 282 284
Condition66%2/3
$lc eq "bytea" or $lc eq "blob"
l!l&&r!l&&!r
02282
MC/DC50%1/2
$lc eq "bytea" or $lc eq "blob"
$lc eq "bytea" $lc eq "blob"
Truth table66%2/3
A or B
A= $lc eq "bytea"B= $lc eq "blob"
ABresult
1X1
011
000
201 282 ▶ return 'CLOB' if $lc eq 'clob';
Branch: 1 branch
BranchTrueFalseTotal
if $lc eq "clob" 0 282 282
202  
203 # Boolean
204 282 ▶ return 'NUMBER(1)' if $lc eq 'boolean';
Branch: 1 branch
BranchTrueFalseTotal
if $lc eq "boolean" 1 281 282
205  
206 # Float/double
207 281 ▶ return 'BINARY_FLOAT' if $lc eq 'real';
Branch: 1 branch
BranchTrueFalseTotal
if $lc eq "real" 2 279 281
208 279 ▶ return 'BINARY_DOUBLE' if $lc eq 'double precision' || $lc eq 'double';
Branch: 1 branch
BranchTrueFalseTotal
if $lc eq "double precision" or $lc eq "double" 9 270 279
Condition100%3/3
$lc eq "double precision" or $lc eq "double"
l!l&&r!l&&!r
54270
MC/DC100%2/2
$lc eq "double precision" or $lc eq "double"
$lc eq "double precision" $lc eq "double"
Truth table100%3/3
A or B
A= $lc eq "double precision"B= $lc eq "double"
ABresult
1X1
011
000
209 270 ▶ if ($lc eq 'float') {
Branch: 1 branch
BranchTrueFalseTotal
if ($lc eq "float") 19 251 270
210 19 ▶ DBIO::Exception->throw(sprintf
Branch: 2 branches
BranchTrueFalseTotal
if defined $size and ref $size || !($size =~ /\A[0-9]+\z/) || $size < 1 || $size > 126 9 10 19
ref $size ? : 1 8 9
Condition100%12/12
defined $size and ref $size || !($size =~ /\A[0-9]+\z/) || $size < 1 || $size > 126
!ll&&!rl&&r
469
ref $size or not $size =~ /\A[0-9]+\z/ or $size < 1 or $size > 126
l!l&&r!l&&!r
726
ref $size or not $size =~ /\A[0-9]+\z/ or $size < 1
l!l&&r!l&&!r
618
ref $size or not $size =~ /\A[0-9]+\z/
l!l&&r!l&&!r
159
MC/DC100%5/5
defined $size and ref $size || !($size =~ /\A[0-9]+\z/) || $size < 1 || $size > 126
defined $size ref $size not $size =~ /\A[0-9]+\z/ $size < 1 $size > 126
Truth table100%6/6
A and B or not(C) or D or E
A= defined $sizeB= ref $sizeC= not $size =~ /\A[0-9]+\z/D= $size < 1E= $size > 126
ABCDEresult
0XXXX0
100000
11XXX1
101XX1
1001X1
100011
211 'float takes a binary precision, a whole number from 1 to 126, not %s; refused',
212 ref $size ? 'a ' . ref($size) . ' reference' : "'$size'")
213 if defined $size && (ref $size || $size !~ /\A[0-9]+\z/ || $size < 1 || $size > 126);
214 10 return $sized->('FLOAT');
215 }
216  
217 # Numeric/decimal — size may be a scalar precision or [precision, scale]
218 251 ▶ return $sized->('NUMBER') if $lc eq 'numeric' || $lc eq 'decimal';
Branch: 1 branch
BranchTrueFalseTotal
if $lc eq "numeric" or $lc eq "decimal" 233 18 251
Condition66%2/3
$lc eq "numeric" or $lc eq "decimal"
l!l&&r!l&&!r
233018
MC/DC50%1/2
$lc eq "numeric" or $lc eq "decimal"
$lc eq "numeric" $lc eq "decimal"
Truth table66%2/3
A or B
A= $lc eq "numeric"B= $lc eq "decimal"
ABresult
1X1
011
000
219  
220 # Fallback — pass through uppercase, with the size it was given (RAW(16)).
221 # An interval carries its precision inside the name, not after it:
222 # INTERVAL YEAR(3) TO MONTH, INTERVAL DAY(3) TO SECOND(4).
223 18 ▶ if ($lc eq 'interval year to month') {
Branch: 1 branch
BranchTrueFalseTotal
if ($lc eq "interval year to month") 2 16 18
224 2 ▶ return defined $size ? "INTERVAL YEAR($size) TO MONTH" : 'INTERVAL YEAR TO MONTH';
Branch: 1 branch
BranchTrueFalseTotal
defined $size ? : 1 1 2
225 }
226 16 ▶ if ($lc eq 'interval day to second') {
Branch: 1 branch
BranchTrueFalseTotal
if ($lc eq "interval day to second") 4 12 16
227 4 ▶ my ($day, $sec) = ref $size eq 'ARRAY' ? @$size : ($size);
Branch: 1 branch
BranchTrueFalseTotal
ref $size eq 'ARRAY' ? : 1 3 4
228 4 ▶ return 'INTERVAL DAY' . (defined $day ? "($day)" : '')
Branch: 2 branches
BranchTrueFalseTotal
defined $day ? : 1 3 4
defined $sec ? : 1 3 4
229 . ' TO SECOND' . (defined $sec ? "($sec)" : '');
230 }
231 12 ▶ return uc $type if $lc =~ /^interval\b/;
Branch: 1 branch
BranchTrueFalseTotal
if $lc =~ /^interval\b/ 0 12 12
232 12 return $sized->(uc $type);
233 }
234  
235 58 1;
236  
237 __END__
« Oracle/DDL.pm ↑ Summary Oracle/Introspect/ForeignKeys.pm »