DB/Informix.pm

filter: Statementstmt 16.1% 57 / 354 Branchbran 0.0% 0 / 178 Conditioncond 0.9% 1 / 102 MC/DCmcdc 0.0% 0 / 57 Subroutinesub 22.2% 16 / 72 Podpod 50.9% 26 / 51 totaltotal 12.2% 100 / 814 CC 119 SCAR 35.5
CC
119
Cov
9%
list_tables
156.0
parse_set
107.3
supports_limit_with_offset
72.0
CRAP 34.8
« DB.pm ↑ Summary DB/Cache.pm »
1 package Rose::DB::Informix;
2  
3 16 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 16 ▶use Rose::DateTime::Util();
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 16 our $VERSION = '0.774';
8  
9 16 our $Debug = 0;
10  
11 use Rose::Class::MakeMethods::Generic
12 16 ▶(
Subroutine BEGIN: called CC=1 SCAR=0.0
13 16 inheritable_scalar =>
14 [
15 'max_array_characters',
16 'default_supports_limit_with_offset',
17 ],
18 16 );
19  
20 16 __PACKAGE__->max_array_characters(255);
21  
22 #
23 # Object methods
24 #
25  
26 sub build_dsn
27 10 ▶{
Subroutine build_dsn: called CC=2 SCAR=8.1
Pod undocumented
28 10 my($self_or_class, %args) = @_;
29 10 ▶ return "dbi:Informix:" . ($args{'db'} || $args{'database'});
Condition33%1/3
$args{'db'} || $args{'database'}
l!l&&r!l&&!r
0100
MC/DC0%0/2
$args{'db'} || $args{'database'}
$args{'db'} $args{'database'}
Truth table33%1/3
A || B
A= $args{'db'}B= $args{'database'}
ABresult
1X1
011
000
30 }
31  
32 0 ▶sub last_insertid_from_sth { $_[1]->{'ix_sqlerrd'}[1] || $_[1]->{'ix_serial8'} }
Subroutine last_insertid_from_sth: not called CC=2 SCAR=17.9
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
$_[1]{"ix_sqlerrd"}[1] or $_[1]{"ix_serial8"} 0 0 0
33  
34 0 ▶sub likes_lowercase_table_names { 1 }
Subroutine likes_lowercase_table_names: not called CC=1 SCAR=6.9
Pod undocumented
35 0 ▶sub generate_primary_key_values { return; } # old perls seem to like this...
Subroutine generate_primary_key_values: not called CC=1 SCAR=6.9
Pod undocumented
36  
37 sub generate_primary_key_placeholders
38 0 ▶{
Subroutine generate_primary_key_placeholders: not called CC=4 SCAR=30.0
Pod undocumented
39 0 ▶ (@_ == 1 || (@_ > 1 && $_[1] == 1)) ? 0 : ((undef) x $_[1])
Branch: 1 branch
BranchTrueFalseTotal
@_ == 1 || @_ > 1 && $_[1] == 1 ? : 0 0 0
Condition0%0/6
@_ == 1 or @_ > 1 and $_[1] == 1
l!l&&r!l&&!r
000
@_ > 1 and $_[1] == 1
!ll&&!rl&&r
000
MC/DC0%0/3
@_ == 1 or @_ > 1 and $_[1] == 1
@_ == 1 @_ > 1 $_[1] == 1
Truth table0%0/4
A or B and C
A= @_ == 1B= @_ > 1C= $_[1] == 1
ABCresult
1XX1
0111
00X0
0100
40 }
41  
42 # Informix doesn't like anything to be quoted and appears to
43 # accept everything without quotes.
44 0 ▶sub is_reserved_word { 0 }
Subroutine is_reserved_word: not called CC=1 SCAR=6.9
Pod undocumented
45  
46 sub refine_dbi_column_info
47 0 ▶{
Subroutine refine_dbi_column_info: not called CC=3 SCAR=20.3
Pod undocumented
48 0 my($self, $col_info, $meta) = @_;
49  
50 0 my $method = ref($self)->parent_class . '::refine_dbi_column_info';
51  
52 16 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
53 0 $self->$method($col_info);
54  
55 0 my $type_name = $col_info->{'TYPE_NAME'};
56  
57 # Handle "INT8" big integers
58 0 ▶ if($type_name eq 'int' && $col_info->{'informix_collength'} == 10)
Branch: 1 branch
BranchTrueFalseTotal
if ($type_name eq "int" and $col_info->{"informix_collength"} == 10) 0 0 0
Condition0%0/3
$type_name eq "int" and $col_info->{"informix_collength"} == 10
!ll&&!rl&&r
000
MC/DC0%0/2
$type_name eq "int" and $col_info->{"informix_collength"} == 10
$type_name eq "int" $col_info->{"informix_collength"} == 10
Truth table0%0/3
A and B
A= $type_name eq "int"B= $col_info->{"informix_collength"} == 10
ABresult
0X0
100
111
59 {
60 0 $col_info->{'TYPE_NAME'} = 'bigint';
61 }
62  
63 0 return;
64 }
65  
66 # Boolean formatting and parsing
67  
68 0 ▶sub format_boolean { $_[1] ? 't' : 'f' }
Subroutine format_boolean: not called CC=2 SCAR=17.9
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
$_[1] ? : 0 0 0
69  
70 sub parse_boolean
71 0 ▶{
Subroutine parse_boolean: not called CC=6 SCAR=37.4
Pod documented
72 0 my($self, $value) = @_;
73 0 ▶ return $value if($self->validate_boolean_keyword($_[1]) ||
Branch: 1 branch
BranchTrueFalseTotal
if $self->validate_boolean_keyword($_[1]) or $self->keyword_function_calls and $_[1] =~ /^\w+\(.*\)$/ 0 0 0
Condition0%0/6
$self->validate_boolean_keyword($_[1]) or $self->keyword_function_calls and $_[1] =~ /^\w+\(.*\)$/
l!l&&r!l&&!r
000
$self->keyword_function_calls and $_[1] =~ /^\w+\(.*\)$/
!ll&&!rl&&r
000
MC/DC0%0/3
$self->validate_boolean_keyword($_[1]) or $self->keyword_function_calls and $_[1] =~ /^\w+\(.*\)$/
$self->validate_boolean_keyword($_[1]) $self->keyword_function_calls $_[1] =~ /^\w+\(.*\)$/
Truth table0%0/4
A or B and C
A= $self->validate_boolean_keyword($_[1])B= $self->keyword_function_callsC= $_[1] =~ /^\w+\(.*\)$/
ABCresult
1XX1
0111
00X0
0100
74 ($self->keyword_function_calls && $_[1] =~ /^\w+\(.*\)$/));
75 0 ▶ return 1 if($value =~ /^[t1]$/i);
Branch: 1 branch
BranchTrueFalseTotal
if $value =~ /^[t1]$/i 0 0 0
76 0 ▶ return 0 if($value =~ /^[f0]$/i);
Branch: 1 branch
BranchTrueFalseTotal
if $value =~ /^[f0]$/i 0 0 0
77  
78 0 $self->error("Invalid boolean value: '$value'");
79 0 return undef;
80 }
81  
82 # Date formatting
83  
84 sub format_date
85 0 ▶{
Subroutine format_date: not called CC=2 SCAR=17.9
Pod documented
86 0 ▶ return $_[1] if($_[0]->validate_date_keyword($_[1]));
Branch: 1 branch
BranchTrueFalseTotal
if $_[0]->validate_date_keyword($_[1]) 0 0 0
87 0 return Rose::DateTime::Util::format_date($_[1], '%m/%d/%Y');
88 }
89  
90 sub format_datetime
91 0 ▶{
Subroutine format_datetime: not called CC=2 SCAR=17.9
Pod documented
92 0 ▶ return $_[1] if($_[0]->validate_datetime_keyword($_[1]));
Branch: 1 branch
BranchTrueFalseTotal
if $_[0]->validate_datetime_keyword($_[1]) 0 0 0
93 0 return Rose::DateTime::Util::format_date($_[1], '%Y-%m-%d %H:%M:%S');
94 }
95  
96 sub format_datetime_year_to_second
97 0 ▶{
Subroutine format_datetime_year_to_second: not called CC=2 SCAR=17.9
Pod documented
98 0 ▶ return $_[1] if($_[0]->validate_datetime_keyword($_[1]));
Branch: 1 branch
BranchTrueFalseTotal
if $_[0]->validate_datetime_keyword($_[1]) 0 0 0
99 0 return Rose::DateTime::Util::format_date($_[1], '%Y-%m-%d %H:%M:%S');
100 }
101  
102 sub format_datetime_year_to_minute
103 0 ▶{
Subroutine format_datetime_year_to_minute: not called CC=2 SCAR=17.9
Pod documented
104 0 ▶ return $_[1] if($_[0]->validate_datetime_keyword($_[1]));
Branch: 1 branch
BranchTrueFalseTotal
if $_[0]->validate_datetime_keyword($_[1]) 0 0 0
105 0 return Rose::DateTime::Util::format_date($_[1], '%Y-%m-%d %H:%M');
106 }
107  
108 sub format_datetime_year_to_month
109 0 ▶{
Subroutine format_datetime_year_to_month: not called CC=2 SCAR=17.9
Pod documented
110 0 ▶ return $_[1] if($_[0]->validate_datetime_keyword($_[1]));
Branch: 1 branch
BranchTrueFalseTotal
if $_[0]->validate_datetime_keyword($_[1]) 0 0 0
111 0 return Rose::DateTime::Util::format_date($_[1], '%Y-%m');
112 }
113  
114 # sub format_time
115 # {
116 # return $_[1] if($_[0]->validate_time_keyword($_[1]));
117 # return Rose::DateTime::Util::format_date($_[1], '%H:%M:%S');
118 # }
119  
120 sub format_timestamp
121 0 ▶{
Subroutine format_timestamp: not called CC=2 SCAR=17.9
Pod documented
122 0 ▶ return $_[1] if($_[0]->validate_timestamp_keyword($_[1]));
Branch: 1 branch
BranchTrueFalseTotal
if $_[0]->validate_timestamp_keyword($_[1]) 0 0 0
123 0 return Rose::DateTime::Util::format_date($_[1], '%Y-%m-%d %H:%M:%S.%5N');
124 }
125  
126 sub format_datetime_year_to_fraction
127 0 ▶{
Subroutine format_datetime_year_to_fraction: not called CC=3 SCAR=24.8
Pod documented
128 0 my($self, $dt, $fraction) = @_;
129  
130 0 ▶ $fraction ||= 3;
Condition0%0/2
$fraction ||= 3
l!l
00
MC/DC0%0/1
$fraction ||= 3
$fraction
Truth table0%0/2
A
A= $fraction
Aresult
11
00
131  
132 0 ▶ return $dt if($self->validate_datetime_year_to_fraction_keyword($dt));
Branch: 1 branch
BranchTrueFalseTotal
if $self->validate_datetime_year_to_fraction_keyword($dt) 0 0 0
133 0 return Rose::DateTime::Util::format_date($dt, "%Y-%m-%d %H:%M:%S.%${fraction}N");
134 }
135  
136 0 ▶sub format_datetime_year_to_fraction_1 { format_datetime_year_to_fraction(@_, 1) }
Subroutine format_datetime_year_to_fraction_1: not called CC=1 SCAR=6.9
Pod undocumented
137 0 ▶sub format_datetime_year_to_fraction_2 { format_datetime_year_to_fraction(@_, 2) }
Subroutine format_datetime_year_to_fraction_2: not called CC=1 SCAR=6.9
Pod undocumented
138 0 ▶sub format_datetime_year_to_fraction_3 { format_datetime_year_to_fraction(@_, 3) }
Subroutine format_datetime_year_to_fraction_3: not called CC=1 SCAR=6.9
Pod undocumented
139 0 ▶sub format_datetime_year_to_fraction_4 { format_datetime_year_to_fraction(@_, 4) }
Subroutine format_datetime_year_to_fraction_4: not called CC=1 SCAR=6.9
Pod undocumented
140 0 ▶sub format_datetime_year_to_fraction_5 { format_datetime_year_to_fraction(@_, 5) }
Subroutine format_datetime_year_to_fraction_5: not called CC=1 SCAR=6.9
Pod undocumented
141  
142 # Date parsing
143  
144 sub parse_date
145 0 ▶{
Subroutine parse_date: not called CC=4 SCAR=30.0
Pod documented
146 0 my($self, $value) = @_;
147  
148 0 ▶ if(UNIVERSAL::isa($value, 'DateTime') ||
Branch: 1 branch
BranchTrueFalseTotal
if (UNIVERSAL::isa($value, "DateTime") or $self->validate_date_keyword($value)) 0 0 0
Condition0%0/3
UNIVERSAL::isa($value, "DateTime") or $self->validate_date_keyword($value)
l!l&&r!l&&!r
000
MC/DC0%0/2
UNIVERSAL::isa($value, "DateTime") or $self->validate_date_keyword($value)
UNIVERSAL::isa($value, "DateTime") $self->validate_date_keyword($value)
Truth table0%0/3
A or B
A= UNIVERSAL::isa($value, "DateTime")B= $self->validate_date_keyword($value)
ABresult
1X1
011
000
149 $self->validate_date_keyword($value))
150 {
151 0 return $value;
152 }
153  
154 0 my($error, $dt);
155  
156 TRY:
157 {
158 0 local $@;
159 0 eval { $dt = Rose::DateTime::Util::parse_date($value) };
160 0 $error = $@;
161 }
162  
163 0 ▶ if($error)
Branch: 1 branch
BranchTrueFalseTotal
if ($error) 0 0 0
164 {
165 0 $self->error("Could not parse date '$value' - $error");
166 0 return undef;
167 }
168  
169 0 return $dt;
170 }
171  
172 sub parse_datetime
173 0 ▶{
Subroutine parse_datetime: not called CC=4 SCAR=30.0
Pod documented
174 0 my($self, $value) = @_;
175  
176 0 ▶ if(UNIVERSAL::isa($value, 'DateTime') ||
Branch: 1 branch
BranchTrueFalseTotal
if (UNIVERSAL::isa($value, "DateTime") or $self->validate_datetime_keyword($value)) 0 0 0
Condition0%0/3
UNIVERSAL::isa($value, "DateTime") or $self->validate_datetime_keyword($value)
l!l&&r!l&&!r
000
MC/DC0%0/2
UNIVERSAL::isa($value, "DateTime") or $self->validate_datetime_keyword($value)
UNIVERSAL::isa($value, "DateTime") $self->validate_datetime_keyword($value)
Truth table0%0/3
A or B
A= UNIVERSAL::isa($value, "DateTime")B= $self->validate_datetime_keyword($value)
ABresult
1X1
011
000
177 $self->validate_datetime_keyword($value))
178 {
179 0 return $value;
180 }
181  
182 0 my($error, $dt);
183  
184 TRY:
185 {
186 0 local $@;
187 0 eval { $dt = Rose::DateTime::Util::parse_date($value) };
188 0 $error = $@;
189 }
190  
191 0 ▶ if($error)
Branch: 1 branch
BranchTrueFalseTotal
if ($error) 0 0 0
192 {
193 0 $self->error("Could not parse datetime '$value' - $error");
194 0 return undef;
195 }
196  
197 0 return $dt;
198 }
199  
200 sub parse_datetime_year_to_second
201 0 ▶{
Subroutine parse_datetime_year_to_second: not called CC=5 SCAR=34.0
Pod documented
202 0 my($self, $value) = @_;
203  
204 0 ▶ if(UNIVERSAL::isa($value, 'DateTime') ||
Branch: 1 branch
BranchTrueFalseTotal
if (UNIVERSAL::isa($value, "DateTime") or $self->validate_datetime_year_to_second_keyword($value)) 0 0 0
Condition0%0/3
UNIVERSAL::isa($value, "DateTime") or $self->validate_datetime_year_to_second_keyword($value)
l!l&&r!l&&!r
000
MC/DC0%0/2
UNIVERSAL::isa($value, "DateTime") or $self->validate_datetime_year_to_second_keyword($value)
UNIVERSAL::isa($value, "DateTime") $self->validate_datetime_year_to_second_keyword($value)
Truth table0%0/3
A or B
A= UNIVERSAL::isa($value, "DateTime")B= $self->validate_datetime_year_to_second_keyword($value)
ABresult
1X1
011
000
205 $self->validate_datetime_year_to_second_keyword($value))
206 {
207 0 return $value;
208 }
209  
210 0 my($error, $dt);
211  
212 TRY:
213 {
214 0 local $@;
215 0 eval { $dt = Rose::DateTime::Util::parse_date($value) };
216 0 $error = $@;
217 }
218  
219 0 ▶ if($error)
Branch: 1 branch
BranchTrueFalseTotal
if ($error) 0 0 0
220 {
221 0 $self->error("Could not parse datetime year to second '$value' - $error");
222 0 return undef;
223 }
224  
225 0 ▶ $dt->truncate(to => 'second') if(ref $dt);
Branch: 1 branch
BranchTrueFalseTotal
if ref $dt 0 0 0
226  
227 0 return $dt;
228 }
229  
230 sub parse_datetime_year_to_fraction
231 0 ▶{
Subroutine parse_datetime_year_to_fraction: not called CC=6 SCAR=37.4
Pod documented
232 0 my($self, $arg, $fraction) = @_;
233  
234 0 ▶ return $arg if($self->validate_datetime_year_to_fraction_keyword($arg));
Branch: 1 branch
BranchTrueFalseTotal
if $self->validate_datetime_year_to_fraction_keyword($arg) 0 0 0
235  
236 0 ▶ $fraction ||= 3;
Condition0%0/2
$fraction ||= 3
l!l
00
MC/DC0%0/1
$fraction ||= 3
$fraction
Truth table0%0/2
A
A= $fraction
Aresult
11
00
237  
238 0 my($error, $dt);
239  
240 TRY:
241 {
242 0 local $@;
243 0 eval { $dt = Rose::DateTime::Util::parse_date($arg) };
244 0 $error = $@;
245 }
246  
247 0 ▶ if($error)
Branch: 1 branch
BranchTrueFalseTotal
if ($error) 0 0 0
248 {
249 0 $self->error("Could not parse datetime year to fraction '$arg' - $error");
250 0 return undef;
251 }
252  
253 0 ▶ if(ref $dt)
Branch: 1 branch
BranchTrueFalseTotal
if (ref $dt) 0 0 0
254 {
255 # Truncate nanosecs to correct fraction. (Yes, using strings. I am lame.)
256 0 my $n = sprintf('%09d', $dt->nanosecond);
257 0 $n = substr($n, 0, $fraction);
258  
259 0 ▶ if(length $n < 9)
Branch: 1 branch
BranchTrueFalseTotal
if (length $n < 9) 0 0 0
260 {
261 0 $n .= ('0' x (9 - length $n));
262 }
263  
264 0 $dt->set_nanosecond($n);
265 }
266  
267 0 return $dt;
268 }
269  
270 0 ▶*parse_datetime_year_to_fraction_1 = sub { parse_datetime_year_to_fraction(@_, 1) };
Subroutine __ANON__: not called CC=1 SCAR=1.2
271 0 ▶*parse_datetime_year_to_fraction_2 = sub { parse_datetime_year_to_fraction(@_, 2) };
Subroutine __ANON__: not called CC=1 SCAR=1.2
272 0 ▶*parse_datetime_year_to_fraction_3 = sub { parse_datetime_year_to_fraction(@_, 3) };
Subroutine __ANON__: not called CC=1 SCAR=1.2
273 0 ▶*parse_datetime_year_to_fraction_4 = sub { parse_datetime_year_to_fraction(@_, 4) };
Subroutine __ANON__: not called CC=1 SCAR=1.2
274 0 ▶*parse_datetime_year_to_fraction_5 = sub { parse_datetime_year_to_fraction(@_, 5) };
Subroutine __ANON__: not called CC=1 SCAR=1.2
275  
276 sub parse_datetime_year_to_minute
277 0 ▶{
Subroutine parse_datetime_year_to_minute: not called CC=5 SCAR=34.0
Pod documented
278 0 my($self, $value) = @_;
279  
280 0 ▶ if(UNIVERSAL::isa($value, 'DateTime') ||
Branch: 1 branch
BranchTrueFalseTotal
if (UNIVERSAL::isa($value, "DateTime") or $self->validate_datetime_year_to_minute_keyword($value)) 0 0 0
Condition0%0/3
UNIVERSAL::isa($value, "DateTime") or $self->validate_datetime_year_to_minute_keyword($value)
l!l&&r!l&&!r
000
MC/DC0%0/2
UNIVERSAL::isa($value, "DateTime") or $self->validate_datetime_year_to_minute_keyword($value)
UNIVERSAL::isa($value, "DateTime") $self->validate_datetime_year_to_minute_keyword($value)
Truth table0%0/3
A or B
A= UNIVERSAL::isa($value, "DateTime")B= $self->validate_datetime_year_to_minute_keyword($value)
ABresult
1X1
011
000
281 $self->validate_datetime_year_to_minute_keyword($value))
282 {
283 0 return $value;
284 }
285  
286 0 my($error, $dt);
287  
288 TRY:
289 {
290 0 local $@;
291 0 eval { $dt = Rose::DateTime::Util::parse_date($value) };
292 0 $error = $@;
293 }
294  
295 0 ▶ if($error)
Branch: 1 branch
BranchTrueFalseTotal
if ($error) 0 0 0
296 {
297 0 $self->error("Could not parse datetime year to minute '$value' - $error");
298 0 return undef;
299 }
300  
301 0 ▶ $dt->truncate(to => 'minute') if(ref $dt);
Branch: 1 branch
BranchTrueFalseTotal
if ref $dt 0 0 0
302  
303 0 return $dt;
304 }
305  
306 sub parse_datetime_year_to_month
307 0 ▶{
Subroutine parse_datetime_year_to_month: not called CC=7 SCAR=40.3
Pod documented
308 0 my($self, $value) = @_;
309  
310 0 ▶ if(UNIVERSAL::isa($value, 'DateTime') ||
Branch: 1 branch
BranchTrueFalseTotal
if (UNIVERSAL::isa($value, "DateTime") or $self->validate_datetime_year_to_month_keyword($value)) 0 0 0
Condition0%0/3
UNIVERSAL::isa($value, "DateTime") or $self->validate_datetime_year_to_month_keyword($value)
l!l&&r!l&&!r
000
MC/DC0%0/2
UNIVERSAL::isa($value, "DateTime") or $self->validate_datetime_year_to_month_keyword($value)
UNIVERSAL::isa($value, "DateTime") $self->validate_datetime_year_to_month_keyword($value)
Truth table0%0/3
A or B
A= UNIVERSAL::isa($value, "DateTime")B= $self->validate_datetime_year_to_month_keyword($value)
ABresult
1X1
011
000
311 $self->validate_datetime_year_to_month_keyword($value))
312 {
313 0 return $value;
314 }
315  
316 0 ▶ if($value =~ m{^(\d\d?)/(\d{4})$})
Branch: 2 branches
BranchTrueFalseTotal
if ($value =~ m[^(\d\d?)/(\d{4})$]) { } 0 0 0
elsif ($value =~ /^\d{4}-\d\d$/) { } 0 0 0
317 {
318 # Add day to MM/YYYY
319 0 $value = "$1/01/$2";
320 }
321 elsif($value =~ /^\d{4}-\d\d$/)
322 {
323 # Append day to YYYY-MM
324 0 $value .= '-01';
325 }
326  
327 0 my($error, $dt);
328  
329 TRY:
330 {
331 0 local $@;
332 0 eval { $dt = Rose::DateTime::Util::parse_date($value) };
333 0 $error = $@;
334 }
335  
336 0 ▶ if($error)
Branch: 1 branch
BranchTrueFalseTotal
if ($error) 0 0 0
337 {
338 0 $self->error("Could not parse datetime year to month '$value' - $error");
339 0 return undef;
340 }
341  
342 0 ▶ $dt->truncate(to => 'month') if(ref $dt);
Branch: 1 branch
BranchTrueFalseTotal
if ref $dt 0 0 0
343  
344 0 return $dt;
345 }
346  
347 sub parse_timestamp
348 0 ▶{
Subroutine parse_timestamp: not called CC=4 SCAR=30.0
Pod documented
349 0 my($self, $value) = @_;
350  
351 0 ▶ if(UNIVERSAL::isa($value, 'DateTime') ||
Branch: 1 branch
BranchTrueFalseTotal
if (UNIVERSAL::isa($value, "DateTime") or $self->validate_timestamp_keyword($value)) 0 0 0
Condition0%0/3
UNIVERSAL::isa($value, "DateTime") or $self->validate_timestamp_keyword($value)
l!l&&r!l&&!r
000
MC/DC0%0/2
UNIVERSAL::isa($value, "DateTime") or $self->validate_timestamp_keyword($value)
UNIVERSAL::isa($value, "DateTime") $self->validate_timestamp_keyword($value)
Truth table0%0/3
A or B
A= UNIVERSAL::isa($value, "DateTime")B= $self->validate_timestamp_keyword($value)
ABresult
1X1
011
000
352 $self->validate_timestamp_keyword($value))
353 {
354 0 return $value;
355 }
356  
357 0 my($error, $dt);
358  
359 TRY:
360 {
361 0 local $@;
362 0 eval { $dt = Rose::DateTime::Util::parse_date($value) };
363 0 $error = $@;
364 }
365  
366 0 ▶ if($error)
Branch: 1 branch
BranchTrueFalseTotal
if ($error) 0 0 0
367 {
368 0 $self->error("Could not parse timestamp '$value' - $error");
369 0 return undef;
370 }
371  
372 0 return $dt;
373 }
374  
375 sub validate_date_keyword
376 0 ▶{
Subroutine validate_date_keyword: not called CC=3 SCAR=19.2
Pod documented
377 16 ▶ no warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
378 0 ▶ $_[1] =~ /^(?:current|today)$/i ||
Branch: 1 branch
BranchTrueFalseTotal
$_[1] =~ /^(?:current|today)$/i or $_[0]->keyword_function_calls and $_[1] =~ /^\w+\(.*\)$/ 0 0 0
Condition0%0/6
$_[1] =~ /^(?:current|today)$/i || $_[0]->keyword_function_calls && $_[1] =~ /^\w+\(.*\)$/
l!l&&r!l&&!r
000
$_[0]->keyword_function_calls and $_[1] =~ /^\w+\(.*\)$/
!ll&&!rl&&r
000
MC/DC0%0/3
$_[1] =~ /^(?:current|today)$/i || $_[0]->keyword_function_calls && $_[1] =~ /^\w+\(.*\)$/
$_[1] =~ /^(?:current|today)$/i $_[0]->keyword_function_calls $_[1] =~ /^\w+\(.*\)$/
Truth table0%0/4
A || B and C
A= $_[1] =~ /^(?:current|today)$/iB= $_[0]->keyword_function_callsC= $_[1] =~ /^\w+\(.*\)$/
ABCresult
1XX1
0111
00X0
0100
379 ($_[0]->keyword_function_calls && $_[1] =~ /^\w+\(.*\)$/);
380 }
381  
382 sub validate_time_keyword
383 0 ▶{
Subroutine validate_time_keyword: not called CC=3 SCAR=19.2
Pod undocumented
384 16 ▶ no warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
385 0 ▶ lc $_[1] eq 'current' ||
Branch: 1 branch
BranchTrueFalseTotal
lc $_[1] eq "current" or $_[0]->keyword_function_calls and $_[1] =~ /^\w+\(.*\)$/ 0 0 0
Condition0%0/6
lc $_[1] eq 'current' || $_[0]->keyword_function_calls && $_[1] =~ /^\w+\(.*\)$/
l!l&&r!l&&!r
000
$_[0]->keyword_function_calls and $_[1] =~ /^\w+\(.*\)$/
!ll&&!rl&&r
000
MC/DC0%0/3
lc $_[1] eq 'current' || $_[0]->keyword_function_calls && $_[1] =~ /^\w+\(.*\)$/
lc $_[1] eq 'current' $_[0]->keyword_function_calls $_[1] =~ /^\w+\(.*\)$/
Truth table0%0/4
A || B and C
A= lc $_[1] eq 'current'B= $_[0]->keyword_function_callsC= $_[1] =~ /^\w+\(.*\)$/
ABCresult
1XX1
0111
00X0
0100
386 ($_[0]->keyword_function_calls && $_[1] =~ /^\w+\(.*\)$/);
387 }
388  
389 sub validate_timestamp_keyword
390 0 ▶{
Subroutine validate_timestamp_keyword: not called CC=3 SCAR=19.2
Pod documented
391 16 ▶ no warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
392 0 ▶ $_[1] =~ /^(?:current(?: +year +to +(?:fraction(?:\([1-5]\))?|second|minute|hour|day|month))?|today)$/i ||
Branch: 1 branch
BranchTrueFalseTotal
$_[1] =~ /^(?:current(?: +year +to +(?:fraction(?:\([1-5]\))?|second|minute|hour|day|month))?|today)$/i or $_[0]->keyword_function_calls and $_[1] =~ /^\w+\(.*\)$/ 0 0 0
Condition0%0/6
$_[1] =~ /^(?:current(?: +year +to +(?:fraction(?:\([1-5]\))?|second|minute|hour|day|month))?|today)$/i || $_[0]->keyword_function_calls && $_[1] =~ /^\w+\(.*\)$/
l!l&&r!l&&!r
000
$_[0]->keyword_function_calls and $_[1] =~ /^\w+\(.*\)$/
!ll&&!rl&&r
000
MC/DC0%0/3
$_[1] =~ /^(?:current(?: +year +to +(?:fraction(?:\([1-5]\))?|second|minute|hour|day|month))?|today)$/i || $_[0]->keyword_function_calls && $_[1] =~ /^\w+\(.*\)$/
$_[1] =~ /^(?:current(?: +year +to +(?:fraction(?:\([1-5]\))?|second|minute|hour|day|month))?|today)$/i $_[0]->keyword_function_calls $_[1] =~ /^\w+\(.*\)$/
Truth table0%0/4
A || B and C
A= $_[1] =~ /^(?:current(?: +year +to +(?:fraction(?:\([1-5]\))?|second|minute|hour|day|month))?|today)$/iB= $_[0]->keyword_function_callsC= $_[1] =~ /^\w+\(.*\)$/
ABCresult
1XX1
0111
00X0
0100
393 ($_[0]->keyword_function_calls && $_[1] =~ /^\w+\(.*\)$/);
394 }
395  
396 sub validate_datetime_year_to_fraction_keyword
397 0 ▶{
Subroutine validate_datetime_year_to_fraction_keyword: not called CC=3 SCAR=19.2
Pod documented
398 16 ▶ no warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
399 0 ▶ $_[1] =~ /^(?:current(?: +year +to +(?:fraction(?:\([1-5]\))?|second|minute|hour|day|month))?|today)$/i ||
Branch: 1 branch
BranchTrueFalseTotal
$_[1] =~ /^(?:current(?: +year +to +(?:fraction(?:\([1-5]\))?|second|minute|hour|day|month))?|today)$/i or $_[0]->keyword_function_calls and $_[1] =~ /^\w+\(.*\)$/ 0 0 0
Condition0%0/6
$_[1] =~ /^(?:current(?: +year +to +(?:fraction(?:\([1-5]\))?|second|minute|hour|day|month))?|today)$/i || $_[0]->keyword_function_calls && $_[1] =~ /^\w+\(.*\)$/
l!l&&r!l&&!r
000
$_[0]->keyword_function_calls and $_[1] =~ /^\w+\(.*\)$/
!ll&&!rl&&r
000
MC/DC0%0/3
$_[1] =~ /^(?:current(?: +year +to +(?:fraction(?:\([1-5]\))?|second|minute|hour|day|month))?|today)$/i || $_[0]->keyword_function_calls && $_[1] =~ /^\w+\(.*\)$/
$_[1] =~ /^(?:current(?: +year +to +(?:fraction(?:\([1-5]\))?|second|minute|hour|day|month))?|today)$/i $_[0]->keyword_function_calls $_[1] =~ /^\w+\(.*\)$/
Truth table0%0/4
A || B and C
A= $_[1] =~ /^(?:current(?: +year +to +(?:fraction(?:\([1-5]\))?|second|minute|hour|day|month))?|today)$/iB= $_[0]->keyword_function_callsC= $_[1] =~ /^\w+\(.*\)$/
ABCresult
1XX1
0111
00X0
0100
400 ($_[0]->keyword_function_calls && $_[1] =~ /^\w+\(.*\)$/);
401 }
402  
403 sub validate_datetime_keyword
404 0 ▶{
Subroutine validate_datetime_keyword: not called CC=3 SCAR=19.2
Pod documented
405 16 ▶ no warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
406 0 ▶ $_[1] =~ /^(?:current(?: +year +to +(?:second|minute|hour|day|month))?|today)$/i ||
Branch: 1 branch
BranchTrueFalseTotal
$_[1] =~ /^(?:current(?: +year +to +(?:second|minute|hour|day|month))?|today)$/i or $_[0]->keyword_function_calls and $_[1] =~ /^\w+\(.*\)$/ 0 0 0
Condition0%0/6
$_[1] =~ /^(?:current(?: +year +to +(?:second|minute|hour|day|month))?|today)$/i || $_[0]->keyword_function_calls && $_[1] =~ /^\w+\(.*\)$/
l!l&&r!l&&!r
000
$_[0]->keyword_function_calls and $_[1] =~ /^\w+\(.*\)$/
!ll&&!rl&&r
000
MC/DC0%0/3
$_[1] =~ /^(?:current(?: +year +to +(?:second|minute|hour|day|month))?|today)$/i || $_[0]->keyword_function_calls && $_[1] =~ /^\w+\(.*\)$/
$_[1] =~ /^(?:current(?: +year +to +(?:second|minute|hour|day|month))?|today)$/i $_[0]->keyword_function_calls $_[1] =~ /^\w+\(.*\)$/
Truth table0%0/4
A || B and C
A= $_[1] =~ /^(?:current(?: +year +to +(?:second|minute|hour|day|month))?|today)$/iB= $_[0]->keyword_function_callsC= $_[1] =~ /^\w+\(.*\)$/
ABCresult
1XX1
0111
00X0
0100
407 ($_[0]->keyword_function_calls && $_[1] =~ /^\w+\(.*\)$/);
408 }
409  
410 sub validate_datetime_year_to_second_keyword
411 0 ▶{
Subroutine validate_datetime_year_to_second_keyword: not called CC=3 SCAR=19.2
Pod documented
412 16 ▶ no warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
413 0 ▶ $_[1] =~ /^(?:current(?: +year +to +(?:second|minute|hour|day|month))?|today)$/i ||
Branch: 1 branch
BranchTrueFalseTotal
$_[1] =~ /^(?:current(?: +year +to +(?:second|minute|hour|day|month))?|today)$/i or $_[0]->keyword_function_calls and $_[1] =~ /^\w+\(.*\)$/ 0 0 0
Condition0%0/6
$_[1] =~ /^(?:current(?: +year +to +(?:second|minute|hour|day|month))?|today)$/i || $_[0]->keyword_function_calls && $_[1] =~ /^\w+\(.*\)$/
l!l&&r!l&&!r
000
$_[0]->keyword_function_calls and $_[1] =~ /^\w+\(.*\)$/
!ll&&!rl&&r
000
MC/DC0%0/3
$_[1] =~ /^(?:current(?: +year +to +(?:second|minute|hour|day|month))?|today)$/i || $_[0]->keyword_function_calls && $_[1] =~ /^\w+\(.*\)$/
$_[1] =~ /^(?:current(?: +year +to +(?:second|minute|hour|day|month))?|today)$/i $_[0]->keyword_function_calls $_[1] =~ /^\w+\(.*\)$/
Truth table0%0/4
A || B and C
A= $_[1] =~ /^(?:current(?: +year +to +(?:second|minute|hour|day|month))?|today)$/iB= $_[0]->keyword_function_callsC= $_[1] =~ /^\w+\(.*\)$/
ABCresult
1XX1
0111
00X0
0100
414 ($_[0]->keyword_function_calls && $_[1] =~ /^\w+\(.*\)$/);
415 }
416  
417 sub validate_datetime_year_to_minute_keyword
418 0 ▶{
Subroutine validate_datetime_year_to_minute_keyword: not called CC=3 SCAR=19.2
Pod documented
419 16 ▶ no warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
420 0 ▶ $_[1] =~ /^(?:current(?: +year +to +(?:second|minute|hour|day|month))?|today)$/i ||
Branch: 1 branch
BranchTrueFalseTotal
$_[1] =~ /^(?:current(?: +year +to +(?:second|minute|hour|day|month))?|today)$/i or $_[0]->keyword_function_calls and $_[1] =~ /^\w+\(.*\)$/ 0 0 0
Condition0%0/6
$_[1] =~ /^(?:current(?: +year +to +(?:second|minute|hour|day|month))?|today)$/i || $_[0]->keyword_function_calls && $_[1] =~ /^\w+\(.*\)$/
l!l&&r!l&&!r
000
$_[0]->keyword_function_calls and $_[1] =~ /^\w+\(.*\)$/
!ll&&!rl&&r
000
MC/DC0%0/3
$_[1] =~ /^(?:current(?: +year +to +(?:second|minute|hour|day|month))?|today)$/i || $_[0]->keyword_function_calls && $_[1] =~ /^\w+\(.*\)$/
$_[1] =~ /^(?:current(?: +year +to +(?:second|minute|hour|day|month))?|today)$/i $_[0]->keyword_function_calls $_[1] =~ /^\w+\(.*\)$/
Truth table0%0/4
A || B and C
A= $_[1] =~ /^(?:current(?: +year +to +(?:second|minute|hour|day|month))?|today)$/iB= $_[0]->keyword_function_callsC= $_[1] =~ /^\w+\(.*\)$/
ABCresult
1XX1
0111
00X0
0100
421 ($_[0]->keyword_function_calls && $_[1] =~ /^\w+\(.*\)$/);
422 }
423  
424 sub validate_datetime_year_to_month_keyword
425 0 ▶{
Subroutine validate_datetime_year_to_month_keyword: not called CC=3 SCAR=19.2
Pod documented
426 16 ▶ no warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
427 0 ▶ $_[1] =~ /^(?:current(?: +year +to +(?:second|minute|hour|day|month))?|today)$/i ||
Branch: 1 branch
BranchTrueFalseTotal
$_[1] =~ /^(?:current(?: +year +to +(?:second|minute|hour|day|month))?|today)$/i or $_[0]->keyword_function_calls and $_[1] =~ /^\w+\(.*\)$/ 0 0 0
Condition0%0/6
$_[1] =~ /^(?:current(?: +year +to +(?:second|minute|hour|day|month))?|today)$/i || $_[0]->keyword_function_calls && $_[1] =~ /^\w+\(.*\)$/
l!l&&r!l&&!r
000
$_[0]->keyword_function_calls and $_[1] =~ /^\w+\(.*\)$/
!ll&&!rl&&r
000
MC/DC0%0/3
$_[1] =~ /^(?:current(?: +year +to +(?:second|minute|hour|day|month))?|today)$/i || $_[0]->keyword_function_calls && $_[1] =~ /^\w+\(.*\)$/
$_[1] =~ /^(?:current(?: +year +to +(?:second|minute|hour|day|month))?|today)$/i $_[0]->keyword_function_calls $_[1] =~ /^\w+\(.*\)$/
Truth table0%0/4
A || B and C
A= $_[1] =~ /^(?:current(?: +year +to +(?:second|minute|hour|day|month))?|today)$/iB= $_[0]->keyword_function_callsC= $_[1] =~ /^\w+\(.*\)$/
ABCresult
1XX1
0111
00X0
0100
428 ($_[0]->keyword_function_calls && $_[1] =~ /^\w+\(.*\)$/);
429 }
430  
431 0 ▶sub should_inline_date_keyword { 1 }
Subroutine should_inline_date_keyword: not called CC=1 SCAR=6.9
Pod undocumented
432 0 ▶sub should_inline_datetime_keyword { 1 }
Subroutine should_inline_datetime_keyword: not called CC=1 SCAR=6.9
Pod undocumented
433 0 ▶sub should_inline_time_keyword { 1 }
Subroutine should_inline_time_keyword: not called CC=1 SCAR=6.9
Pod undocumented
434 0 ▶sub should_inline_timestamp_keyword { 1 }
Subroutine should_inline_timestamp_keyword: not called CC=1 SCAR=6.9
Pod undocumented
435  
436 sub parse_set
437 0 ▶{
Subroutine parse_set: not called CC=11 SCAR=46.8
Pod documented
438 0 my($self) = shift;
439  
440 0 ▶ return $_[0] if(ref $_[0] eq 'ARRAY');
Branch: 1 branch
BranchTrueFalseTotal
if ref $_[0] eq "ARRAY" 0 0 0
441  
442 0 ▶ if(@_ > 1 && !ref $_[1])
Branch: 1 branch
BranchTrueFalseTotal
if (@_ > 1 and not ref $_[1]) 0 0 0
Condition0%0/3
@_ > 1 and not ref $_[1]
!ll&&!rl&&r
000
MC/DC0%0/2
@_ > 1 and not ref $_[1]
@_ > 1 not ref $_[1]
Truth table0%0/3
A and not(B)
A= @_ > 1B= not ref $_[1]
ABresult
0X0
100
111
443 {
444 0 pop(@_);
445 0 return [ @_ ];
446 }
447  
448 0 my $val = $_[0];
449  
450 0 ▶ return undef unless(defined $val);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $val 0 0 0
451  
452 0 ▶ my $options = ref $_[-1] eq 'HASH' ? $_[-1] : {};
Branch: 1 branch
BranchTrueFalseTotal
ref $_[-1] eq 'HASH' ? : 0 0 0
453  
454 16 ▶ no warnings 'uninitialized';
Subroutine BEGIN: called CC=1 SCAR=0.0
455 my $numeric =
456 0 ▶ ($options->{'value_type'} =~ /^(?:(?:big)?(?:float|int(?:eger)?|num(?:eric)?)|decimal)$/i) ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$options->{'value_type'} =~ /^(?:(?:big)?(?:float|int(?:eger)?|num(?:eric)?)|decimal)$/i ? : 0 0 0
457  
458 0 ▶ return undef unless(defined $val);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $val 0 0 0
459  
460 0 $val =~ s/^SET\{(.*)\}$/$1/;
461  
462 0 my @set;
463  
464 0 ▶ while($val =~ s/(?:'((?:[^'\\]+|\\.)*)'|([^',]+))(?:,|$)//)
Branch: 1 branch
BranchTrueFalseTotal
if ($val =~ s/(?:'((?:[^'\\]+|\\.)*)'|([^',]+))(?:,|$)//) 0 0 0
465 {
466 0 ▶ push(@set, (defined $1) ? $1 : $2);
Branch: 1 branch
BranchTrueFalseTotal
defined $1 ? : 0 0 0
467  
468 0 ▶ if($numeric)
Branch: 1 branch
BranchTrueFalseTotal
if ($numeric) 0 0 0
469 {
470 0 $set[-1] =~ s/\s+//g;
471 }
472 }
473  
474 0 return \@set;
475 }
476  
477 sub format_set
478 0 ▶{
Subroutine format_set: not called CC=6 SCAR=37.4
Pod documented
479 0 my($self) = shift;
480  
481 0 ▶ my @set = (ref $_[0]) ? @{$_[0]} : @_;
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] ? : 0 0 0
482  
483 0 ▶ return undef unless(@set && defined $set[0]);
Branch: 1 branch
BranchTrueFalseTotal
unless @set and defined $set[0] 0 0 0
Condition0%0/3
@set and defined $set[0]
!ll&&!rl&&r
000
MC/DC0%0/2
@set and defined $set[0]
@set defined $set[0]
Truth table0%0/3
A and B
A= @setB= defined $set[0]
ABresult
0X0
100
111
484  
485 return 'SET{' . join(',', map
486 {
487 0 ▶ if(!defined $_)
Branch: 2 branches
BranchTrueFalseTotal
if (not defined $_) { } 0 0 0
elsif (/^[-+]?\d+(?:\.\d*)?$/) { } 0 0 0
488 {
489 0 Carp::croak 'Undefined value found in array or list passed to ',
490 __PACKAGE__, '::format_set()';
491 }
492 elsif(/^[-+]?\d+(?:\.\d*)?$/)
493 {
494 0 $_
495 }
496 else
497 {
498 0 s/\\/\\\\/g;
499 0 s/'/\\'/g;
500 0 qq('$_')
501 }
502 } @set) . '}';
503 }
504  
505 sub parse_array
506 0 ▶{
Subroutine parse_array: not called CC=6 SCAR=37.4
Pod documented
507 0 my($self) = shift;
508  
509 0 ▶ return $_[0] if(ref $_[0]);
Branch: 1 branch
BranchTrueFalseTotal
if ref $_[0] 0 0 0
510 0 ▶ return [ @_ ] if(@_ > 1);
Branch: 1 branch
BranchTrueFalseTotal
if @_ > 1 0 0 0
511  
512 0 my $val = $_[0];
513  
514 0 ▶ return undef unless(defined $val);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $val 0 0 0
515  
516 0 $val =~ s/^\{(.*)\}$/$1/;
517  
518 0 my @array;
519  
520 0 ▶ while($val =~ s/(?:"((?:[^"\\]+|\\.)*)"|([^",]+))(?:,|$)//)
Branch: 1 branch
BranchTrueFalseTotal
if ($val =~ s/(?:"((?:[^"\\]+|\\.)*)"|([^",]+))(?:,|$)//) 0 0 0
521 {
522 0 ▶ push(@array, (defined $1) ? $1 : $2);
Branch: 1 branch
BranchTrueFalseTotal
defined $1 ? : 0 0 0
523 }
524  
525 0 return \@array;
526 }
527  
528 sub format_array
529 0 ▶{
Subroutine format_array: not called CC=7 SCAR=40.3
Pod documented
530 0 my($self) = shift;
531  
532 0 ▶ my @array = (ref $_[0]) ? @{$_[0]} : @_;
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] ? : 0 0 0
533  
534 0 ▶ return undef unless(@array && defined $array[0]);
Branch: 1 branch
BranchTrueFalseTotal
unless @array and defined $array[0] 0 0 0
Condition0%0/3
@array and defined $array[0]
!ll&&!rl&&r
000
MC/DC0%0/2
@array and defined $array[0]
@array defined $array[0]
Truth table0%0/3
A and B
A= @arrayB= defined $array[0]
ABresult
0X0
100
111
535  
536 my $str = '{' . join(',', map
537 {
538 0 ▶ if(!defined $_)
Branch: 2 branches
BranchTrueFalseTotal
if (not defined $_) { } 0 0 0
elsif (/^[-+]?\d+(?:\.\d*)?$/) { } 0 0 0
539 {
540 0 Carp::croak 'Undefined value found in array or list passed to ',
541 __PACKAGE__, '::format_array()';
542 }
543 elsif(/^[-+]?\d+(?:\.\d*)?$/)
544 {
545 0 $_
546 }
547 else
548 {
549 0 s/\\/\\\\/g;
550 0 s/"/\\"/g;
551 0 qq("$_")
552 }
553 } @array) . '}';
554  
555 0 ▶ if(length($str) > $self->max_array_characters)
Branch: 1 branch
BranchTrueFalseTotal
if (length $str > $self->max_array_characters) 0 0 0
556 {
557 0 Carp::croak "Array string is longer than ", ref($self),
558 "->max_array_characters (", $self->max_array_characters,
559 ") characters long: $str";
560 }
561  
562 0 return $str;
563 }
564  
565 sub next_value_in_sequence
566 0 ▶{
Subroutine next_value_in_sequence: not called CC=3 SCAR=24.8
Pod undocumented
567 0 my($self, $seq) = @_;
568  
569 0 ▶ my $dbh = $self->dbh or return undef;
Branch: 1 branch
BranchTrueFalseTotal
my $dbh = $self->dbh or return undef 0 0 0
570  
571 0 my($error, $id);
572  
573 TRY:
574 {
575 0 local $@;
576  
577 eval
578 0 {
579 0 my $sth = $dbh->prepare(qq(SELECT nextval('$seq')));
580 0 $sth->execute;
581 0 $id = ${$sth->fetchrow_arrayref}[0];
582 };
583  
584 0 $error = $@;
585 }
586  
587 0 ▶ if($error)
Branch: 1 branch
BranchTrueFalseTotal
if ($error) 0 0 0
588 {
589 0 $self->error("Could not get the next value in the sequence '$seq' - $error");
590 0 return undef;
591 }
592  
593 0 return $id;
594 }
595  
596 16 ▶use constant VERSION_SQL =>
Subroutine BEGIN: called CC=1 SCAR=0.0
597 16 q(SELECT FIRST 1 DBINFO('version', 'major') from 'informix'.systables);
598  
599 16 our %Major_Version_Cache;
600  
601 16 ▶use constant MAX_TO_CACHE => 500;
Subroutine BEGIN: called CC=1 SCAR=0.0
602  
603 sub supports_limit_with_offset
604 0 ▶{
Subroutine supports_limit_with_offset: not called CC=8 SCAR=42.8
Pod undocumented
605 0 my($self) = shift;
606  
607 0 my $ok = ref($self)->default_supports_limit_with_offset;
608 0 ▶ return $ok if(defined $ok);
Branch: 1 branch
BranchTrueFalseTotal
if defined $ok 0 0 0
609  
610 0 ▶ my $dbh = $self->dbh or return 0;
Branch: 1 branch
BranchTrueFalseTotal
my $dbh = $self->dbh or return 0 0 0 0
611  
612 0 ▶ unless(defined $Major_Version_Cache{$dbh})
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $Rose::DB::Informix::Major_Version_Cache{$dbh}) 0 0 0
613 {
614 0 my $version;
615  
616 TRY:
617 {
618 0 local $@;
619  
620 eval
621 0 {
622 0 ▶ $Debug && warn VERSION_SQL, "\n";
Branch: 1 branch
BranchTrueFalseTotal
$Rose::DB::Informix::Debug and warn "SELECT FIRST 1 DBINFO('version', 'major') from 'informix'.systables", "\n" 0 0 0
623 0 my $sth = $dbh->prepare(VERSION_SQL);
624 0 $sth->execute;
625 0 ($version) = $sth->fetchrow_array;
626 };
627  
628 # Intentionally ignore any errors
629 }
630  
631 0 ▶ %Major_Version_Cache = () if(keys %Major_Version_Cache > MAX_TO_CACHE);
Branch: 1 branch
BranchTrueFalseTotal
if keys %Rose::DB::Informix::Major_Version_Cache > 500 0 0 0
632 0 ▶ $Major_Version_Cache{$dbh} = $version || 0;
Condition0%0/2
$version || 0
l!l
00
MC/DC0%0/1
$version || 0
$version
Truth table0%0/2
A
A= $version
Aresult
11
00
633 }
634  
635 0 ▶ return $Major_Version_Cache{$dbh} >= 10 ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$Rose::DB::Informix::Major_Version_Cache{$dbh} >= 10 ? : 0 0 0
636 0 return 0;
637 }
638  
639  
640 sub format_limit_with_offset
641 0 ▶{
Subroutine format_limit_with_offset: not called CC=2 SCAR=17.9
Pod undocumented
642 0 my($self, $limit, $offset, $args) = @_;
643  
644 0 delete $args->{'limit'};
645 0 delete $args->{'offset'};
646  
647 0 ▶ if(defined $offset)
Branch: 1 branch
BranchTrueFalseTotal
if (defined $offset) { } 0 0 0
648 {
649 0 $args->{'limit_prefix'} = "SKIP $offset FIRST $limit";
650 }
651 else
652 {
653 0 $args->{'limit_prefix'} = "FIRST $limit";
654 }
655 }
656  
657 0 ▶sub supports_select_from_subselect { 0 } # can't handle serial columns in multiset
Subroutine supports_select_from_subselect: not called CC=1 SCAR=6.9
Pod undocumented
658 0 ▶sub format_select_from_subselect { "\nTABLE(MULTISET(($_[1])))\n " }
Subroutine format_select_from_subselect: not called CC=1 SCAR=6.9
Pod undocumented
659  
660 sub format_select_start_sql
661 0 ▶{
Subroutine format_select_start_sql: not called CC=4 SCAR=30.0
Pod undocumented
662 0 my($self, $hints) = @_;
663  
664 0 ▶ return 'SELECT' unless($hints);
Branch: 1 branch
BranchTrueFalseTotal
unless $hints 0 0 0
665  
666 my $comment =
667 join(' ', ($hints->{'comment'} ? $hints->{'comment'} : ()),
668 0 ▶ (map { $hints->{$_} ? uc("+$_") : () } qw(first_rows all_rows)));
Branch: 2 branches
BranchTrueFalseTotal
$hints->{'comment'} ? : 0 0 0
$hints->{$_} ? : 0 0 0
669  
670 0 return "SELECT {$comment}";
671 }
672  
673 #
674 # Introspection
675 #
676  
677 sub list_tables
678 0 ▶{
Subroutine list_tables: not called CC=12 SCAR=50.5
Pod undocumented
679 0 my($self, %args) = @_;
680  
681 0 my(@tables, $error);
682  
683 TRY:
684 {
685 0 local $@;
686  
687 eval
688 0 {
689 0 ▶ my $dbh = $self->dbh or die $self->error;
Branch: 1 branch
BranchTrueFalseTotal
my $dbh = $self->dbh or die $self->error 0 0 0
690  
691 0 local $dbh->{'RaiseError'} = 1;
692  
693 0 my @table_info = $dbh->func('user', '_tables');
694  
695 0 my $schema = $self->schema;
696  
697 #if($args{'include_views'})
698 #{
699 # my @view_info = $dbh->func('view', '_tables');
700 # push(@table_info, @view_info);
701 #}
702  
703 0 my %seen;
704  
705 0 foreach my $item (@table_info)
706 {
707 # From DBD::Informix::Metadata:
708 #
709 # The owner name will be enclosed in double quotes; if it contains
710 # double quotes, those will be doubled up as required by SQL. The
711 # table name will only be enclosed in double quotes if it is not a
712 # valid C identifier (meaning, it starts with an alphabetic
713 # character or underscore, and continues with alphanumeric
714 # characters or underscores). If it is enclosed in double quotes,
715 # any embedded double quotes are doubled up.
716 #
717 # "jsiracusa ".test
718  
719 0 ▶ if($item =~ /^(?: "((?:""|[^"]+)+)" | ([^"]+) ) \. (?: "((?:""|[^"]+)+)" | ([^"]+) )$/x)
Branch: 1 branch
BranchTrueFalseTotal
if ($item =~ /^(?: "((?:""|[^"]+)+)" | ([^"]+) ) \. (?: "((?:""|[^"]+)+)" | ([^"]+) )$/x) { } 0 0 0
720 {
721 0 ▶ my $user = defined $1 ? $1 : $2;
Branch: 1 branch
BranchTrueFalseTotal
defined $1 ? : 0 0 0
722 0 ▶ my $table = defined $3 ? $3 : $4;
Branch: 1 branch
BranchTrueFalseTotal
defined $3 ? : 0 0 0
723  
724 0 for($user, $table)
725 {
726 0 s/""/"/g;
727 }
728  
729 0 ▶ next if($seen{$table}++);
Branch: 1 branch
BranchTrueFalseTotal
if $seen{$table}++ 0 0 0
730  
731 0 ▶ if(!defined $schema || $schema eq $user)
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $schema or $schema eq $user) 0 0 0
Condition0%0/3
not defined $schema or $schema eq $user
l!l&&r!l&&!r
000
MC/DC0%0/2
not defined $schema or $schema eq $user
not defined $schema $schema eq $user
Truth table0%0/3
not(A) or B
A= not defined $schemaB= $schema eq $user
ABresult
1X1
011
000
732 {
733 0 push(@tables, $table);
734 }
735 }
736 else
737 {
738 0 Carp::carp "Could not parse table information: $item";
739 }
740 }
741 };
742  
743 0 $error = $@;
744 }
745  
746 0 ▶ if($error)
Branch: 1 branch
BranchTrueFalseTotal
if ($error) 0 0 0
747 {
748 0 Carp::croak "Could not list tables from ", $self->dsn, " - $error";
749 }
750  
751 0 ▶ return wantarray ? @tables : \@tables;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 0 0
752 }
753  
754 sub _get_primary_key_column_names
755 0 ▶{
Subroutine _get_primary_key_column_names: not called CC=4 SCAR=30.0
756 0 my($self, $catalog, $schema, $table_arg) = @_;
757  
758 0 require DBD::Informix::Metadata;
759  
760 0 ▶ my $dbh = $self->dbh or die $self->error;
Branch: 1 branch
BranchTrueFalseTotal
my $dbh = $self->dbh or die $self->error 0 0 0
761  
762 0 local $dbh->{'FetchHashKeyName'} = 'NAME';
763  
764 # We need the table owner. Asking for column information is the only
765 # way I know of to reliably get this information.
766 #
767 # Informix does not support DBI's column_info() method so we have
768 # to get all that into "the hard way."
769 #
770 # Each item in @col_list is a reference to an array of values:
771 #
772 # 0 owner name
773 # 1 table name
774 # 2 column number
775 # 3 column name
776 # 4 data type (encoded)
777 # 5 data length (encoded)
778 #
779 0 my @col_list = DBD::Informix::Metadata::ix_columns($dbh, $table_arg);
780  
781 0 my $owner = $col_list[0][0];
782 0 my $table = $col_list[0][1]; # just in case...
783  
784 0 ▶ unless(defined $owner)
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $owner) 0 0 0
785 {
786 #die "Could not find owner for table ", $table;
787  
788 # Failure to find an owner is sometimes caused by
789 # DBD::Informix::Metadata's annoying habit of returning
790 # sequences along with the list of tables. So we'll just
791 # say that it has no primary key columns.
792 0 return [];
793 }
794  
795 # Then comes this monster query to get the primary key column names.
796 # I'd love to know a better/easier way to do this...
797 0 my $pk_sth = $dbh->prepare(<<'EOF');
798 SELECT
799 col.colname
800 FROM
801 informix.sysconstraints con,
802 informix.systables tab,
803 informix.sysindexes idx,
804 informix.syscolumns col
805 WHERE
806 constrtype = 'P' AND
807 con.tabid = tab.tabid AND
808 con.tabid = idx.tabid AND
809 con.tabid = col.tabid AND
810 con.idxname = idx.idxname
811 AND
812 (
813 col.colno = idx.part1 OR
814 col.colno = idx.part2 OR
815 col.colno = idx.part3 OR
816 col.colno = idx.part4 OR
817 col.colno = idx.part5 OR
818 col.colno = idx.part6 OR
819 col.colno = idx.part7 OR
820 col.colno = idx.part8 OR
821 col.colno = idx.part9 OR
822 col.colno = idx.part10 OR
823 col.colno = idx.part11 OR
824 col.colno = idx.part12 OR
825 col.colno = idx.part13 OR
826 col.colno = idx.part14 OR
827 col.colno = idx.part15 OR
828 col.colno = idx.part16
829 )
830 AND
831 tab.tabname = ? AND
832 tab.owner = ?
833 EOF
834  
835 0 $pk_sth->execute($table, $owner);
836  
837 0 my(@columns, $column);
838  
839 0 $pk_sth->bind_columns(\$column);
840  
841 0 ▶ while($pk_sth->fetch)
Branch: 1 branch
BranchTrueFalseTotal
if ($pk_sth->fetch) 0 0 0
842 {
843 0 push(@columns, $column);
844 }
845  
846 0 return \@columns;
847 }
848  
849 16 1;
850  
851 __END__
« DB.pm ↑ Summary DB/Cache.pm »