DB/Pg.pm

filter: Statementstmt 27.7% 98 / 353 Branchbran 1.6% 3 / 184 Conditioncond 1.0% 1 / 97 MC/DCmcdc 0.0% 0 / 52 Subroutinesub 43.2% 29 / 67 Podpod 28.2% 11 / 39 totaltotal 17.9% 142 / 792 CC 124 SCAR 49.7
CC
124
Cov
16%
refine_dbi_column_info
690.5
format_select_lock
210.0
parse_dbi_column_info_default
107.3
CRAP 143.5
↑ Summary DB/SQLite.pm »
1 package Rose::DB::Pg;
2  
3 17 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 17 ▶no warnings 'uninitialized';
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 17 ▶use DateTime::Infinite;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 17 ▶use DateTime::Format::Pg;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 17 ▶use SQL::ReservedWords::PostgreSQL();
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 17 ▶use Rose::DB;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 17 our $VERSION = '0.786'; # overshot version number, freeze until caught up
13  
14 17 our $DBD_PG_AFTER_380; # set in refine_dbi_foreign_key_info()
15  
16 17 our $Debug = 0;
17  
18  
19 #
20 # Class data
21 #
22  
23 use Rose::Class::MakeMethods::Generic
24 17 ▶(
Subroutine BEGIN: called CC=1 SCAR=0.0
25 17 inheritable_scalar =>
26 [
27 '_timestamps_are_inlined',
28 ],
29 17 );
30  
31 17 __PACKAGE__->timestamps_are_inlined(0);
32  
33  
34 #
35 # Class methods
36 #
37  
38 sub timestamps_are_inlined
39 17 ▶{
Subroutine timestamps_are_inlined: called CC=3 SCAR=11.8
Pod documented
40 17 my($class) = shift;
41  
42 17 ▶ if(@_)
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 17 0 17
43 {
44 17 my $arg = shift;
45  
46 17 $class->_timestamps_are_inlined($arg);
47  
48 17 ▶ return $arg ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$arg ? : 0 17 17
49 }
50  
51 0 return $class->_timestamps_are_inlined;
52 }
53  
54  
55 #
56 # Object data
57 #
58  
59 use Rose::Object::MakeMethods::Generic
60 17 ▶(
Subroutine BEGIN: called CC=1 SCAR=0.0
61 17 'scalar' =>
62 [
63 qw(sslmode service options)
64 ],
65 17 );
66  
67  
68 #
69 # Object methods
70 #
71  
72 sub build_dsn
73 10 ▶{
Subroutine build_dsn: called CC=2 SCAR=7.1
Pod undocumented
74 10 my($self_or_class, %args) = @_;
75  
76 10 my %info;
77  
78 10 ▶ $info{'dbname'} = $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
79  
80 @info{qw(host port options service sslmode)} =
81 10 @args{qw(host port options service sslmode)};
82  
83 return
84 "dbi:Pg:" .
85 10 join(';', map { "$_=$info{$_}" } grep { defined $info{$_} }
86 qw(dbname host port options service sslmode));
87 }
88  
89 36 ▶sub dbi_driver { 'Pg' }
Subroutine dbi_driver: called CC=1 SCAR=0.0
Pod undocumented
90  
91 sub init_date_handler
92 0 ▶{
Subroutine init_date_handler: not called CC=3 SCAR=19.6
Pod undocumented
93 0 my($self) = shift;
94  
95 0 my $parent_class = ref($self)->parent_class;
96 0 my $european_dates = "${parent_class}::european_dates";
97 0 my $server_time_zone = "${parent_class}::server_time_zone";
98  
99 17 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
100 0 ▶ my $parser =
Branch: 2 branches
BranchTrueFalseTotal
$self->$european_dates ? : 0 0 0
$self->$server_time_zone ? : 0 0 0
101 DateTime::Format::Pg->new(
102 ($self->$european_dates() ? (european => 1) : ()),
103 ($self->$server_time_zone() ?
104 (server_tz => $self->$server_time_zone()) : ()));
105  
106 0 return $parser;
107 }
108  
109 0 ▶sub default_implicit_schema { 'public' }
Subroutine default_implicit_schema: not called CC=1 SCAR=6.9
Pod undocumented
110 0 ▶sub likes_lowercase_table_names { 1 }
Subroutine likes_lowercase_table_names: not called CC=1 SCAR=6.9
Pod undocumented
111 0 ▶sub likes_lowercase_schema_names { 1 }
Subroutine likes_lowercase_schema_names: not called CC=1 SCAR=6.9
Pod undocumented
112 0 ▶sub likes_lowercase_catalog_names { 1 }
Subroutine likes_lowercase_catalog_names: not called CC=1 SCAR=6.9
Pod undocumented
113 0 ▶sub likes_lowercase_sequence_names { 1 }
Subroutine likes_lowercase_sequence_names: not called CC=1 SCAR=6.9
Pod undocumented
114  
115 0 ▶sub supports_multi_column_count_distinct { 0 }
Subroutine supports_multi_column_count_distinct: not called CC=1 SCAR=6.9
Pod undocumented
116 0 ▶sub supports_arbitrary_defaults_on_insert { 1 }
Subroutine supports_arbitrary_defaults_on_insert: not called CC=1 SCAR=6.9
Pod undocumented
117 0 ▶sub supports_select_from_subselect { 1 }
Subroutine supports_select_from_subselect: not called CC=1 SCAR=6.9
Pod undocumented
118  
119 0 ▶sub pg_enable_utf8 { shift->dbh_attribute_boolean('pg_enable_utf8', @_) }
Subroutine pg_enable_utf8: not called CC=1 SCAR=6.9
Pod documented
120  
121 0 ▶sub supports_schema { 1 }
Subroutine supports_schema: not called CC=1 SCAR=6.9
Pod undocumented
122  
123 0 ▶sub max_column_name_length { 63 }
Subroutine max_column_name_length: not called CC=1 SCAR=6.9
Pod undocumented
124 0 ▶sub max_column_alias_length { 63 }
Subroutine max_column_alias_length: not called CC=1 SCAR=6.9
Pod undocumented
125  
126 sub last_insertid_from_sth
127 0 ▶{
Subroutine last_insertid_from_sth: not called CC=1 SCAR=6.9
Pod undocumented
128 #my($self, $sth, $obj) = @_;
129  
130 # PostgreSQL demands that the primary key column not be in the insert
131 # statement at all in order for it to auto-generate a value. The
132 # insert SQL will need to be modified to make this work for
133 # Rose::DB::Object...
134 #if($DBD::Pg::VERSION >= 1.40)
135 #{
136 # my $meta = $obj->meta;
137 # return $self->dbh->last_insert_id(undef, $meta->select_schema, $meta->table, undef);
138 #}
139  
140 0 return undef;
141 }
142  
143 sub format_select_lock
144 0 ▶{
Subroutine format_select_lock: not called CC=14 SCAR=53.5
Pod undocumented
145 0 my($self, $class, $lock, $tables_list) = @_;
146  
147 0 ▶ $lock = { type => $lock } unless(ref $lock);
Branch: 1 branch
BranchTrueFalseTotal
unless ref $lock 0 0 0
148  
149 0 ▶ $lock->{'type'} ||= 'for update' if($lock->{'for_update'});
Branch: 1 branch
BranchTrueFalseTotal
if $lock->{"for_update"} 0 0 0
Condition0%0/2
$lock->{"type"} ||= "for update"
l!l
00
MC/DC0%0/1
$lock->{"type"} ||= "for update"
$lock->{"type"}
Truth table0%0/2
A
A= $lock->{"type"}
Aresult
11
00
150  
151 0 my %types =
152 (
153 'for update' => 'FOR UPDATE',
154 'shared' => 'FOR SHARE',
155 );
156  
157 0 ▶ my $sql = $types{$lock->{'type'}}
Branch: 1 branch
BranchTrueFalseTotal
my $sql = $types{$lock->{"type"}} or Carp::croak(qq[Invalid lock type: $lock->{"type"}]) 0 0 0
158 or Carp::croak "Invalid lock type: $lock->{'type'}";
159  
160 0 my @tables;
161  
162 0 ▶ if(my $on = $lock->{'on'})
Branch: 2 branches
BranchTrueFalseTotal
if (my $on = $lock->{'on'}) { } 0 0 0
elsif (my $lock_tables = $lock->{'tables'}) { } 0 0 0
163 {
164 0 @tables = map { $self->table_sql_from_lock_on_value($class, $_, $tables_list) } @$on;
165 }
166 elsif(my $lock_tables = $lock->{'tables'})
167 {
168 0 my %map;
169  
170 0 ▶ if($tables_list)
Branch: 1 branch
BranchTrueFalseTotal
if ($tables_list) 0 0 0
171 {
172 0 my $tn = 1;
173  
174 0 foreach my $table (@$tables_list)
175 {
176 0 (my $table_key = $table) =~ s/^(["']?)[^.]+\1\.//;
177 0 $map{$table_key} = 't' . $tn++;
178 }
179 }
180  
181 @tables = map
182 {
183 0 ref $_ eq 'SCALAR' ? $$_ :
184 0 ▶ $self->auto_quote_table_name(defined $map{$_} ? $map{$_} : $_)
Branch: 2 branches
BranchTrueFalseTotal
ref $_ eq 'SCALAR' ? : 0 0 0
defined $map{$_} ? : 0 0 0
185 }
186 @$lock_tables;
187 }
188  
189 0 ▶ if(@tables)
Branch: 1 branch
BranchTrueFalseTotal
if (@tables) 0 0 0
190 {
191 0 $sql .= ' OF ' . join(', ', @tables);
192 }
193  
194 0 ▶ $sql .= ' NOWAIT' if($lock->{'nowait'});
Branch: 1 branch
BranchTrueFalseTotal
if $lock->{"nowait"} 0 0 0
195  
196 0 ▶ $sql .= ' SKIP LOCKED' if($lock->{'skip_locked'});
Branch: 1 branch
BranchTrueFalseTotal
if $lock->{"skip_locked"} 0 0 0
197  
198 0 return $sql;
199 }
200  
201 sub parse_datetime
202 0 ▶{
Subroutine parse_datetime: not called CC=4 SCAR=21.7
Pod undocumented
203 0 my($self) = shift;
204  
205 0 ▶ unless(ref $_[0])
Branch: 1 branch
BranchTrueFalseTotal
unless (ref $_[0]) 0 0 0
206 {
207 17 ▶ no warnings 'uninitialized';
Subroutine BEGIN: called CC=1 SCAR=0.0
208 0 ▶ return DateTime::Infinite::Past->new if($_[0] eq '-infinity');
Branch: 1 branch
BranchTrueFalseTotal
if $_[0] eq "-infinity" 0 0 0
209 0 ▶ return DateTime::Infinite::Future->new if($_[0] eq 'infinity');
Branch: 1 branch
BranchTrueFalseTotal
if $_[0] eq "infinity" 0 0 0
210 }
211  
212 0 my $method = ref($self)->parent_class . '::parse_datetime';
213  
214 17 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
215 0 $self->$method(@_);
216 }
217  
218 sub parse_timestamp
219 0 ▶{
Subroutine parse_timestamp: not called CC=4 SCAR=21.7
Pod undocumented
220 0 my($self) = shift;
221  
222 0 ▶ unless(ref $_[0])
Branch: 1 branch
BranchTrueFalseTotal
unless (ref $_[0]) 0 0 0
223 {
224 17 ▶ no warnings 'uninitialized';
Subroutine BEGIN: called CC=1 SCAR=0.0
225 0 ▶ return DateTime::Infinite::Past->new if($_[0] eq '-infinity');
Branch: 1 branch
BranchTrueFalseTotal
if $_[0] eq "-infinity" 0 0 0
226 0 ▶ return DateTime::Infinite::Future->new if($_[0] eq 'infinity');
Branch: 1 branch
BranchTrueFalseTotal
if $_[0] eq "infinity" 0 0 0
227 }
228  
229 0 my $method = ref($self)->parent_class . '::parse_timestamp';
230  
231 17 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
232 0 $self->$method(@_);
233 }
234  
235 sub parse_timestamp_with_time_zone
236 0 ▶{
Subroutine parse_timestamp_with_time_zone: not called CC=4 SCAR=21.7
Pod undocumented
237 0 my($self, $value) = @_;
238  
239 0 ▶ unless(ref $value)
Branch: 1 branch
BranchTrueFalseTotal
unless (ref $value) 0 0 0
240 {
241 17 ▶ no warnings 'uninitialized';
Subroutine BEGIN: called CC=1 SCAR=0.0
242 0 ▶ return DateTime::Infinite::Past->new if($value eq '-infinity');
Branch: 1 branch
BranchTrueFalseTotal
if $value eq "-infinity" 0 0 0
243 0 ▶ return DateTime::Infinite::Future->new if($value eq 'infinity');
Branch: 1 branch
BranchTrueFalseTotal
if $value eq "infinity" 0 0 0
244 }
245  
246 0 my $method = ref($self)->parent_class . '::parse_timestamp_with_time_zone';
247  
248 17 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
249 0 shift->$method(@_);
250 }
251  
252 sub validate_date_keyword
253 0 ▶{
Subroutine validate_date_keyword: not called CC=3 SCAR=19.2
Pod documented
254 17 ▶ no warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
255 0 ▶ $_[1] =~ /^(?:(?:now|timeofday)(?:\(\))?|(?:current_(?:date|time(?:stamp)?)
Branch: 1 branch
BranchTrueFalseTotal
$_[1] =~ /^(?:(?:now|timeofday)(?:\(\))?|(?:current_(?:date|time(?:stamp)?) |localtime(?:stamp)?)(?:\(\d*\))?|epoch|today|tomorrow|yesterday|)$/xi or $_[0]->keyword_function_calls and $_[1] =~ /^\w+\(.*\)$/ 0 0 0
Condition0%0/6
$_[1] =~ /^(?:(?:now|timeofday)(?:\(\))?|(?:current_(?:date|time(?:stamp)?) |localtime(?:stamp)?)(?:\(\d*\))?|epoch|today|tomorrow|yesterday|)$/xi || $_[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] =~ /^(?:(?:now|timeofday)(?:\(\))?|(?:current_(?:date|time(?:stamp)?) |localtime(?:stamp)?)(?:\(\d*\))?|epoch|today|tomorrow|yesterday|)$/xi || $_[0]->keyword_function_calls && $_[1] =~ /^\w+\(.*\)$/
$_[1] =~ /^(?:(?:now|timeofday)(?:\(\))?|(?:current_(?:date|time(?:stamp)?) |localtime(?:stamp)?)(?:\(\d*\))?|epoch|today|tomorrow|yesterday|)$/xi $_[0]->keyword_function_calls $_[1] =~ /^\w+\(.*\)$/
Truth table0%0/4
A || B and C
A= $_[1] =~ /^(?:(?:now|timeofday)(?:\(\))?|(?:current_(?:date|time(?:stamp)?) |localtime(?:stamp)?)(?:\(\d*\))?|epoch|today|tomorrow|yesterday|)$/xiB= $_[0]->keyword_function_callsC= $_[1] =~ /^\w+\(.*\)$/
ABCresult
1XX1
0111
00X0
0100
256 |localtime(?:stamp)?)(?:\(\d*\))?|epoch|today|tomorrow|yesterday|)$/xi ||
257 ($_[0]->keyword_function_calls && $_[1] =~ /^\w+\(.*\)$/);
258 }
259  
260 sub validate_time_keyword
261 0 ▶{
Subroutine validate_time_keyword: not called CC=3 SCAR=19.2
Pod documented
262 17 ▶ no warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
263 0 ▶ $_[1] =~ /^(?:(?:now|timeofday)(?:\(\))?|(?:current_(?:date|time(?:stamp)?)
Branch: 1 branch
BranchTrueFalseTotal
$_[1] =~ /^(?:(?:now|timeofday)(?:\(\))?|(?:current_(?:date|time(?:stamp)?) |localtime(?:stamp)?)(?:\(\d*\))?|allballs)$/xi or $_[0]->keyword_function_calls and $_[1] =~ /^\w+\(.*\)$/ 0 0 0
Condition0%0/6
$_[1] =~ /^(?:(?:now|timeofday)(?:\(\))?|(?:current_(?:date|time(?:stamp)?) |localtime(?:stamp)?)(?:\(\d*\))?|allballs)$/xi || $_[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] =~ /^(?:(?:now|timeofday)(?:\(\))?|(?:current_(?:date|time(?:stamp)?) |localtime(?:stamp)?)(?:\(\d*\))?|allballs)$/xi || $_[0]->keyword_function_calls && $_[1] =~ /^\w+\(.*\)$/
$_[1] =~ /^(?:(?:now|timeofday)(?:\(\))?|(?:current_(?:date|time(?:stamp)?) |localtime(?:stamp)?)(?:\(\d*\))?|allballs)$/xi $_[0]->keyword_function_calls $_[1] =~ /^\w+\(.*\)$/
Truth table0%0/4
A || B and C
A= $_[1] =~ /^(?:(?:now|timeofday)(?:\(\))?|(?:current_(?:date|time(?:stamp)?) |localtime(?:stamp)?)(?:\(\d*\))?|allballs)$/xiB= $_[0]->keyword_function_callsC= $_[1] =~ /^\w+\(.*\)$/
ABCresult
1XX1
0111
00X0
0100
264 |localtime(?:stamp)?)(?:\(\d*\))?|allballs)$/xi ||
265 ($_[0]->keyword_function_calls && $_[1] =~ /^\w+\(.*\)$/);
266 }
267  
268 sub validate_timestamp_keyword
269 0 ▶{
Subroutine validate_timestamp_keyword: not called CC=3 SCAR=19.2
Pod documented
270 17 ▶ no warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
271 0 ▶ $_[1] =~ /^(?:(?:now|timeofday)(?:\(\))?|(?:current_(?:date|time(?:stamp)?)
Branch: 1 branch
BranchTrueFalseTotal
$_[1] =~ /^(?:(?:now|timeofday)(?:\(\))?|(?:current_(?:date|time(?:stamp)?) |localtime(?:stamp)?)(?:\(\d*\))?|-?infinity|epoch|today|tomorrow|yesterday|allballs)$/xi or $_[0]->keyword_function_calls and $_[1] =~ /^\w+\(.*\)$/ 0 0 0
Condition0%0/6
$_[1] =~ /^(?:(?:now|timeofday)(?:\(\))?|(?:current_(?:date|time(?:stamp)?) |localtime(?:stamp)?)(?:\(\d*\))?|-?infinity|epoch|today|tomorrow|yesterday|allballs)$/xi || $_[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] =~ /^(?:(?:now|timeofday)(?:\(\))?|(?:current_(?:date|time(?:stamp)?) |localtime(?:stamp)?)(?:\(\d*\))?|-?infinity|epoch|today|tomorrow|yesterday|allballs)$/xi || $_[0]->keyword_function_calls && $_[1] =~ /^\w+\(.*\)$/
$_[1] =~ /^(?:(?:now|timeofday)(?:\(\))?|(?:current_(?:date|time(?:stamp)?) |localtime(?:stamp)?)(?:\(\d*\))?|-?infinity|epoch|today|tomorrow|yesterday|allballs)$/xi $_[0]->keyword_function_calls $_[1] =~ /^\w+\(.*\)$/
Truth table0%0/4
A || B and C
A= $_[1] =~ /^(?:(?:now|timeofday)(?:\(\))?|(?:current_(?:date|time(?:stamp)?) |localtime(?:stamp)?)(?:\(\d*\))?|-?infinity|epoch|today|tomorrow|yesterday|allballs)$/xiB= $_[0]->keyword_function_callsC= $_[1] =~ /^\w+\(.*\)$/
ABCresult
1XX1
0111
00X0
0100
272 |localtime(?:stamp)?)(?:\(\d*\))?|-?infinity|epoch|today|tomorrow|yesterday|allballs)$/xi ||
273 ($_[0]->keyword_function_calls && $_[1] =~ /^\w+\(.*\)$/);
274  
275 }
276  
277 17 *validate_datetime_keyword = \&validate_timestamp_keyword;
278  
279 sub should_inline_timestamp_keyword
280 0 ▶{
Subroutine should_inline_timestamp_keyword: not called CC=2 SCAR=17.9
Pod undocumented
281 0 my($self) = shift;
282 0 ▶ my $class = ref($self) || $self;
Condition0%0/3
ref $self || $self
l!l&&r!l&&!r
000
MC/DC0%0/2
ref $self || $self
ref $self $self
Truth table0%0/3
A || B
A= ref $selfB= $self
ABresult
1X1
011
000
283 0 return ($class->timestamps_are_inlined);
284 }
285  
286 sub server_time_zone
287 0 ▶{
Subroutine server_time_zone: not called CC=2 SCAR=11.6
Pod documented
288 0 my($self) = shift;
289  
290 0 ▶ $self->{'date_handler'} = undef if(@_);
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 0 0
291  
292 0 my $method = ref($self)->parent_class . '::server_time_zone';
293  
294 17 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
295 0 $self->$method(@_);
296 }
297  
298 sub european_dates
299 0 ▶{
Subroutine european_dates: not called CC=2 SCAR=11.6
Pod documented
300 0 my($self) = shift;
301  
302 0 ▶ $self->{'date_handler'} = undef if(@_);
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 0 0
303  
304 0 my $method = ref($self)->parent_class . '::european_dates';
305  
306 17 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
307 0 $self->$method(@_);
308 }
309  
310 sub parse_array
311 0 ▶{
Subroutine parse_array: not called CC=8 SCAR=42.8
Pod documented
312 0 my($self) = shift;
313  
314 0 ▶ return $_[0] if(ref $_[0]);
Branch: 1 branch
BranchTrueFalseTotal
if ref $_[0] 0 0 0
315 0 ▶ return [ @_ ] if(@_ > 1);
Branch: 1 branch
BranchTrueFalseTotal
if @_ > 1 0 0 0
316  
317 0 my $val = $_[0];
318  
319 0 ▶ return undef unless(defined $val);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $val 0 0 0
320  
321 0 $val =~ s/^ (?:\[.+\]=)? \{ (.*) \} $/$1/sx;
322  
323 0 my @array;
324  
325 0 ▶ while($val =~ s/(?:"((?:[^"\\]+|\\.)*)"|([^",]+))(?:,|$)//)
Branch: 1 branch
BranchTrueFalseTotal
if ($val =~ s/(?:"((?:[^"\\]+|\\.)*)"|([^",]+))(?:,|$)//) 0 0 0
326 {
327 0 ▶ my($item) = map { $_ eq 'NULL' ? undef : $_ } (defined $1 ? $1 : $2);
Branch: 2 branches
BranchTrueFalseTotal
$_ eq 'NULL' ? : 0 0 0
defined $1 ? : 0 0 0
328 0 ▶ $item =~ s{\\(.)}{$1}g if(defined $item);
Branch: 1 branch
BranchTrueFalseTotal
if defined $item 0 0 0
329 0 push(@array, $item);
330 }
331  
332 0 return \@array;
333 }
334  
335 sub format_array
336 0 ▶{
Subroutine format_array: not called CC=7 SCAR=40.3
Pod documented
337 0 my($self) = shift;
338  
339 0 ▶ return undef unless(ref $_[0] || defined $_[0]);
Branch: 1 branch
BranchTrueFalseTotal
unless ref $_[0] or defined $_[0] 0 0 0
Condition0%0/3
ref $_[0] or defined $_[0]
l!l&&r!l&&!r
000
MC/DC0%0/2
ref $_[0] or defined $_[0]
ref $_[0] defined $_[0]
Truth table0%0/3
A or B
A= ref $_[0]B= defined $_[0]
ABresult
1X1
011
000
340  
341 0 ▶ my @array = (ref $_[0]) ? @{$_[0]} : @_;
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] ? : 0 0 0
342  
343 return '{' . join(',', map
344 {
345 0 ▶ if(!defined $_)
Branch: 3 branches
BranchTrueFalseTotal
if (not defined $_) { } 0 0 0
elsif (/^[-+]?\d+(?:\.\d*)?$/) { } 0 0 0
elsif (ref $_ eq 'ARRAY') { } 0 0 0
346 {
347 0 'NULL'
348 }
349 elsif(/^[-+]?\d+(?:\.\d*)?$/)
350 {
351 0 $_
352 }
353 elsif(ref($_) eq 'ARRAY')
354 {
355 0 $self->format_array($_);
356 }
357 else
358 {
359 0 s/\\/\\\\/g;
360 0 s/"/\\"/g;
361 0 qq("$_")
362 }
363 } @array) . '}';
364 }
365  
366 sub parse_interval
367 0 ▶{
Subroutine parse_interval: not called CC=9 SCAR=42.8
Pod documented
368 0 my($self, $value, $end_of_month_mode) = @_;
369  
370 0 ▶ if(!defined $value || UNIVERSAL::isa($value, 'DateTime::Duration') ||
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $value or UNIVERSAL::isa($value, "DateTime::Duration") or $self->validate_interval_keyword($value) or $self->keyword_function_calls and $value =~ /^\w+\(.*\)$/) 0 0 0
Condition0%0/12
not defined $value or UNIVERSAL::isa($value, "DateTime::Duration") or $self->validate_interval_keyword($value) or $self->keyword_function_calls and $value =~ /^\w+\(.*\)$/
l!l&&r!l&&!r
000
not defined $value or UNIVERSAL::isa($value, "DateTime::Duration") or $self->validate_interval_keyword($value)
l!l&&r!l&&!r
000
not defined $value or UNIVERSAL::isa($value, "DateTime::Duration")
l!l&&r!l&&!r
000
$self->keyword_function_calls and $value =~ /^\w+\(.*\)$/
!ll&&!rl&&r
000
MC/DC0%0/5
not defined $value or UNIVERSAL::isa($value, "DateTime::Duration") or $self->validate_interval_keyword($value) or $self->keyword_function_calls and $value =~ /^\w+\(.*\)$/
not defined $value UNIVERSAL::isa($value, "DateTime::Duration") $self->validate_interval_keyword($value) $self->keyword_function_calls $value =~ /^\w+\(.*\)$/
Truth table0%0/6
not(A) or B or C or D and E
A= not defined $valueB= UNIVERSAL::isa($value, "DateTime::Duration")C= $self->validate_interval_keyword($value)D= $self->keyword_function_callsE= $value =~ /^\w+\(.*\)$/
ABCDEresult
1XXXX1
01XXX1
001XX1
000111
0000X0
000100
371 $self->validate_interval_keyword($value) ||
372 ($self->keyword_function_calls && $value =~ /^\w+\(.*\)$/))
373 {
374 0 return $value;
375 }
376  
377 0 my($dt_duration, $error);
378  
379 TRY:
380 {
381 0 local $@;
382 0 eval { $dt_duration = $self->date_handler->parse_interval($value) };
383 0 $error = $@;
384 }
385  
386 0 my $method = ref($self)->parent_class . '::parse_interval';
387  
388 17 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
389 0 ▶ return $self->$method($value, $end_of_month_mode) if($error);
Branch: 1 branch
BranchTrueFalseTotal
if $error 0 0 0
390  
391 0 ▶ if(defined $end_of_month_mode && $dt_duration)
Branch: 1 branch
BranchTrueFalseTotal
if (defined $end_of_month_mode and $dt_duration) 0 0 0
Condition0%0/3
defined $end_of_month_mode and $dt_duration
!ll&&!rl&&r
000
MC/DC0%0/2
defined $end_of_month_mode and $dt_duration
defined $end_of_month_mode $dt_duration
Truth table0%0/3
A and B
A= defined $end_of_month_modeB= $dt_duration
ABresult
0X0
100
111
392 {
393 # XXX: There is no mutator for end_of_month_mode, so I'm being evil
394 # XXX: and setting it directly. Blah.
395 0 $dt_duration->{'end_of_month'} = $end_of_month_mode;
396 }
397  
398 0 return $dt_duration;
399 }
400  
401 BEGIN
402 17 ▶{
Subroutine BEGIN: called CC=2 SCAR=15.8
403 17 require DateTime::Format::Pg;
404  
405 # Handle DateTime::Format::Pg bug
406 # http://rt.cpan.org/Public/Bug/Display.html?id=18487
407 17 ▶ if($DateTime::Format::Pg::VERSION < 0.11)
Branch: 1 branch
BranchTrueFalseTotal
if ($DateTime::Format::Pg::VERSION < 0.11) { } 0 17 17
408 {
409 *format_interval = sub
410 0 ▶ {
Subroutine __ANON__: not called CC=5 SCAR=34.0
411 0 my($self, $dur) = @_;
412 0 ▶ return $dur if(!defined $dur || $self->validate_interval_keyword($dur) ||
Branch: 1 branch
BranchTrueFalseTotal
if not defined $dur or $self->validate_interval_keyword($dur) or $self->keyword_function_calls and $dur =~ /^\w+\(.*\)$/ 0 0 0
Condition0%0/9
not defined $dur or $self->validate_interval_keyword($dur) or $self->keyword_function_calls and $dur =~ /^\w+\(.*\)$/
l!l&&r!l&&!r
000
not defined $dur or $self->validate_interval_keyword($dur)
l!l&&r!l&&!r
000
$self->keyword_function_calls and $dur =~ /^\w+\(.*\)$/
!ll&&!rl&&r
000
MC/DC0%0/4
not defined $dur or $self->validate_interval_keyword($dur) or $self->keyword_function_calls and $dur =~ /^\w+\(.*\)$/
not defined $dur $self->validate_interval_keyword($dur) $self->keyword_function_calls $dur =~ /^\w+\(.*\)$/
Truth table0%0/5
not(A) or B or C and D
A= not defined $durB= $self->validate_interval_keyword($dur)C= $self->keyword_function_callsD= $dur =~ /^\w+\(.*\)$/
ABCDresult
1XXX1
01XX1
00111
000X0
00100
413 ($self->keyword_function_calls && $dur =~ /^\w+\(.*\)$/));
414 0 my $val = $self->date_handler->format_interval($dur);
415  
416 0 $val =~ s/(\S+e\S+) seconds/sprintf('%f seconds', $1)/e;
417 0 return $val;
418 0 };
419 }
420 else
421 {
422 *format_interval = sub
423 0 ▶ {
Subroutine __ANON__: not called CC=5 SCAR=34.0
424 0 my($self, $dur) = @_;
425 0 ▶ return $dur if(!defined $dur || $self->validate_interval_keyword($dur) ||
Branch: 1 branch
BranchTrueFalseTotal
if not defined $dur or $self->validate_interval_keyword($dur) or $self->keyword_function_calls and $dur =~ /^\w+\(.*\)$/ 0 0 0
Condition0%0/9
not defined $dur or $self->validate_interval_keyword($dur) or $self->keyword_function_calls and $dur =~ /^\w+\(.*\)$/
l!l&&r!l&&!r
000
not defined $dur or $self->validate_interval_keyword($dur)
l!l&&r!l&&!r
000
$self->keyword_function_calls and $dur =~ /^\w+\(.*\)$/
!ll&&!rl&&r
000
MC/DC0%0/4
not defined $dur or $self->validate_interval_keyword($dur) or $self->keyword_function_calls and $dur =~ /^\w+\(.*\)$/
not defined $dur $self->validate_interval_keyword($dur) $self->keyword_function_calls $dur =~ /^\w+\(.*\)$/
Truth table0%0/5
not(A) or B or C and D
A= not defined $durB= $self->validate_interval_keyword($dur)C= $self->keyword_function_callsD= $dur =~ /^\w+\(.*\)$/
ABCDresult
1XXX1
01XX1
00111
000X0
00100
426 ($self->keyword_function_calls && $dur =~ /^\w+\(.*\)$/));
427 0 return $self->date_handler->format_interval($dur);
428 17 };
429 }
430 }
431  
432 sub next_value_in_sequence
433 0 ▶{
Subroutine next_value_in_sequence: not called CC=3 SCAR=24.8
Pod documented
434 0 my($self, $sequence_name) = @_;
435  
436 0 ▶ my $dbh = $self->dbh or return undef;
Branch: 1 branch
BranchTrueFalseTotal
my $dbh = $self->dbh or return undef 0 0 0
437  
438 0 my($value, $error);
439  
440 TRY:
441 {
442 0 local $@;
443  
444 eval
445 0 {
446 0 local $dbh->{'PrintError'} = 0;
447 0 local $dbh->{'RaiseError'} = 1;
448 0 my $sth = $dbh->prepare(qq(SELECT nextval(?)));
449 0 $sth->execute($sequence_name);
450 0 $value = ${$sth->fetchrow_arrayref}[0];
451 };
452  
453 0 $error = $@;
454 }
455  
456 0 ▶ if($error)
Branch: 1 branch
BranchTrueFalseTotal
if ($error) 0 0 0
457 {
458 0 $self->error("Could not get the next value in the sequence '$sequence_name' - $error");
459 0 return undef;
460 }
461  
462 0 return $value;
463 }
464  
465 sub current_value_in_sequence
466 0 ▶{
Subroutine current_value_in_sequence: not called CC=3 SCAR=24.8
Pod undocumented
467 0 my($self, $sequence_name) = @_;
468  
469 0 ▶ my $dbh = $self->dbh or return undef;
Branch: 1 branch
BranchTrueFalseTotal
my $dbh = $self->dbh or return undef 0 0 0
470  
471 0 my($value, $error);
472  
473 TRY:
474 {
475 0 local $@;
476  
477 eval
478 0 {
479 0 local $dbh->{'PrintError'} = 0;
480 0 local $dbh->{'RaiseError'} = 1;
481 0 my $name = $dbh->quote_identifier($sequence_name);
482 0 my $sth = $dbh->prepare(qq(SELECT last_value FROM $name));
483 0 $sth->execute;
484 0 $value = ${$sth->fetchrow_arrayref}[0];
485 };
486  
487 0 $error = $@;
488 }
489  
490 0 ▶ if($error)
Branch: 1 branch
BranchTrueFalseTotal
if ($error) 0 0 0
491 {
492 0 $self->error("Could not get the current value in the sequence '$sequence_name' - $error");
493 0 return undef;
494 }
495  
496 0 return $value;
497 }
498  
499 0 ▶sub sequence_exists { defined shift->current_value_in_sequence(@_) ? 1 : 0 }
Subroutine sequence_exists: not called CC=2 SCAR=17.9
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
defined((shift())->current_value_in_sequence(@_)) ? : 0 0 0
500  
501 0 ▶sub use_auto_sequence_name { 1 }
Subroutine use_auto_sequence_name: not called CC=1 SCAR=6.9
Pod undocumented
502  
503 sub auto_sequence_name
504 0 ▶{
Subroutine auto_sequence_name: not called CC=3 SCAR=24.8
Pod undocumented
505 0 my($self, %args) = @_;
506  
507 0 my $table = $args{'table'};
508 0 ▶ Carp::croak "Missing table argument" unless(defined $table);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $table 0 0 0
509  
510 0 my $column = $args{'column'};
511 0 ▶ Carp::croak "Missing column argument" unless(defined $column);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $column 0 0 0
512  
513 0 return lc "${table}_${column}_seq";
514 }
515  
516 17 *is_reserved_word = \&SQL::ReservedWords::PostgreSQL::is_reserved;
517  
518 #
519 # DBI introspection
520 #
521  
522 sub refine_dbi_column_info
523 0 ▶{
Subroutine refine_dbi_column_info: not called CC=29 SCAR=65.4
Pod undocumented
524 0 my($self, $col_info, $meta) = @_;
525  
526 # Save default value
527 0 my $default = $col_info->{'COLUMN_DEF'};
528  
529 0 my $method = ref($self)->parent_class . '::refine_dbi_column_info';
530  
531 17 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
532 0 $self->$method($col_info);
533  
534  
535 0 ▶ if(defined $default)
Branch: 1 branch
BranchTrueFalseTotal
if (defined $default) 0 0 0
536 {
537 # Set sequence name key, if present
538 0 ▶ if($default =~ /^nextval\(\(?'((?:''|[^']+))'::\w+/)
Branch: 2 branches
BranchTrueFalseTotal
if ($default =~ /^nextval\(\(?'((?:''|[^']+))'::\w+/) { } 0 0 0
elsif ($default =~ /^NULL::[\w ]+$/) { } 0 0 0
539 {
540 0 ▶ $col_info->{'rdbo_default_value_sequence_name'} =
Branch: 1 branch
BranchTrueFalseTotal
$self->likes_lowercase_sequence_names ? : 0 0 0
541 $self->likes_lowercase_sequence_names ? lc $1 : $1;
542  
543 0 ▶ if($meta)
Branch: 1 branch
BranchTrueFalseTotal
if ($meta) 0 0 0
544 {
545 0 my $seq = $col_info->{'rdbo_default_value_sequence_name'};
546  
547 0 my $implicit_schema = $self->default_implicit_schema;
548  
549 # Strip off default implicit schema unless a schema is explicitly
550 # specified in the RDBO metadata object.
551 0 ▶ if(defined $seq && defined $implicit_schema && !defined $meta->schema)
Branch: 1 branch
BranchTrueFalseTotal
if (defined $seq and defined $implicit_schema and not defined $meta->schema) 0 0 0
Condition0%0/6
defined $seq and defined $implicit_schema and not defined $meta->schema
!ll&&!rl&&r
000
defined $seq and defined $implicit_schema
!ll&&!rl&&r
000
MC/DC0%0/3
defined $seq and defined $implicit_schema and not defined $meta->schema
defined $seq defined $implicit_schema not defined $meta->schema
Truth table0%0/4
A and B and not(C)
A= defined $seqB= defined $implicit_schemaC= not defined $meta->schema
ABCresult
0XX0
10X0
1100
1111
552 {
553 0 $seq =~ s/^$implicit_schema\.//;
554 }
555  
556 0 $col_info->{'rdbo_default_value_sequence_name'} = $self->unquote_column_name($seq);
557  
558 # Pg returns serial columns as integer or bigint
559 0 ▶ if($col_info->{'TYPE_NAME'} eq 'integer' ||
Branch: 1 branch
BranchTrueFalseTotal
if ($col_info->{"TYPE_NAME"} eq "integer" or $col_info->{"TYPE_NAME"} eq "bigint") 0 0 0
Condition0%0/3
$col_info->{"TYPE_NAME"} eq "integer" or $col_info->{"TYPE_NAME"} eq "bigint"
l!l&&r!l&&!r
000
MC/DC0%0/2
$col_info->{"TYPE_NAME"} eq "integer" or $col_info->{"TYPE_NAME"} eq "bigint"
$col_info->{"TYPE_NAME"} eq "integer" $col_info->{"TYPE_NAME"} eq "bigint"
Truth table0%0/3
A or B
A= $col_info->{"TYPE_NAME"} eq "integer"B= $col_info->{"TYPE_NAME"} eq "bigint"
ABresult
1X1
011
000
560 $col_info->{'TYPE_NAME'} eq 'bigint')
561 {
562 0 my $db = $meta->db;
563  
564 my $auto_seq =
565 $db->auto_sequence_name(table => $meta->table,
566 0 column => $col_info->{'COLUMN_NAME'});
567  
568 # Use schema prefix on auto-generated name if necessary
569 0 ▶ if($seq =~ /^[^.]+\./)
Branch: 1 branch
BranchTrueFalseTotal
if ($seq =~ /^[^.]+\./) 0 0 0
570 {
571 0 my $schema = $meta->select_schema($db);
572 0 ▶ $auto_seq = "$schema.$auto_seq" if($schema);
Branch: 1 branch
BranchTrueFalseTotal
if $schema 0 0 0
573 }
574  
575 17 ▶ no warnings 'uninitialized';
Subroutine BEGIN: called CC=1 SCAR=0.0
576 0 ▶ if(lc $seq eq lc $auto_seq)
Branch: 1 branch
BranchTrueFalseTotal
if (lc $seq eq lc $auto_seq) 0 0 0
577 {
578 $col_info->{'TYPE_NAME'} =
579 0 ▶ $col_info->{'TYPE_NAME'} eq 'integer' ? 'serial' : 'bigserial';
Branch: 1 branch
BranchTrueFalseTotal
$col_info->{'TYPE_NAME'} eq 'integer' ? : 0 0 0
580 }
581 }
582 }
583 }
584 elsif($default =~ /^NULL::[\w ]+$/)
585 {
586 # RT 64331: https://rt.cpan.org/Ticket/Display.html?id=64331
587 0 $col_info->{'COLUMN_DEF'} = undef;
588 }
589 }
590  
591 0 my $type_name = $col_info->{'TYPE_NAME'};
592  
593 # Pg has some odd/different names for types. Convert them to standard forms.
594 0 ▶ if($type_name eq 'character varying')
Branch: 6 branches
BranchTrueFalseTotal
if ($type_name eq 'character varying') { } 0 0 0
elsif ($type_name eq 'bit') { } 0 0 0
elsif ($type_name eq 'real') { } 0 0 0
elsif ($type_name eq 'time without time zone') { } 0 0 0
elsif ($type_name eq 'double precision') { } 0 0 0
elsif ($type_name eq 'money') { } 0 0 0
595 {
596 0 $col_info->{'TYPE_NAME'} = 'varchar';
597 }
598 elsif($type_name eq 'bit')
599 {
600 0 $col_info->{'TYPE_NAME'} = 'bits';
601 }
602 elsif($type_name eq 'real')
603 {
604 0 $col_info->{'TYPE_NAME'} = 'float';
605 }
606 elsif($type_name eq 'time without time zone')
607 {
608 0 $col_info->{'TYPE_NAME'} = 'time';
609 0 $col_info->{'pg_type'} =~ /^time(?:\((\d+)\))? without time zone$/i;
610 0 ▶ $col_info->{'TIME_SCALE'} = $1 || 0;
Condition0%0/2
$1 || 0
l!l
00
MC/DC0%0/1
$1 || 0
$1
Truth table0%0/2
A
A= $1
Aresult
11
00
611 }
612 elsif($type_name eq 'double precision')
613 {
614 0 $col_info->{'COLUMN_SIZE'} = undef;
615 }
616 elsif($type_name eq 'money')
617 {
618 0 $col_info->{'COLUMN_SIZE'} = undef;
619 }
620  
621 # Pg does not populate COLUMN_SIZE correctly for bit fields, so
622 # we have to extract the number of bits from pg_type.
623 0 ▶ if($col_info->{'pg_type'} =~ /^bit\((\d+)\)$/)
Branch: 1 branch
BranchTrueFalseTotal
if ($col_info->{"pg_type"} =~ /^bit\((\d+)\)$/) 0 0 0
624 {
625 0 $col_info->{'COLUMN_SIZE'} = $1;
626 }
627  
628 # Extract precision and scale from numeric types
629 0 ▶ if($col_info->{'pg_type'} =~ /^numeric/i)
Branch: 1 branch
BranchTrueFalseTotal
if ($col_info->{"pg_type"} =~ /^numeric/i) 0 0 0
630 {
631 17 ▶ no warnings 'uninitialized';
Subroutine BEGIN: called CC=1 SCAR=0.0
632  
633 0 ▶ if($col_info->{'COLUMN_SIZE'} =~ /^(\d+),(\d+)$/)
Branch: 2 branches
BranchTrueFalseTotal
if ($col_info->{'COLUMN_SIZE'} =~ /^(\d+),(\d+)$/) { } 0 0 0
elsif ($col_info->{'pg_type'} =~ /^numeric\((\d+),(\d+)\)$/i) { } 0 0 0
634 {
635 0 $col_info->{'COLUMN_SIZE'} = $1;
636 0 $col_info->{'DECIMAL_DIGITS'} = $2;
637 }
638 elsif($col_info->{'pg_type'} =~ /^numeric\((\d+),(\d+)\)$/i)
639 {
640 0 $col_info->{'COLUMN_SIZE'} = $2;
641 0 $col_info->{'DECIMAL_DIGITS'} = $1;
642 }
643 }
644  
645 # Treat custom types that look like enums as enums
646 0 ▶ if(ref $col_info->{'pg_enum_values'} && @{$col_info->{'pg_enum_values'}})
Branch: 1 branch
BranchTrueFalseTotal
if (ref $col_info->{"pg_enum_values"} and @{$col_info->{"pg_enum_values"};}) 0 0 0
Condition0%0/3
ref $col_info->{"pg_enum_values"} and @{$col_info->{"pg_enum_values"};}
!ll&&!rl&&r
000
MC/DC0%0/2
ref $col_info->{"pg_enum_values"} and @{$col_info->{"pg_enum_values"};}
ref $col_info->{"pg_enum_values"} @{$col_info->{"pg_enum_values"};}
Truth table0%0/3
A and B
A= ref $col_info->{"pg_enum_values"}B= @{$col_info->{"pg_enum_values"};}
ABresult
0X0
100
111
647 {
648 0 $col_info->{'TYPE_NAME'} = 'enum';
649 0 $col_info->{'RDBO_ENUM_VALUES'} = $col_info->{'pg_enum_values'};
650 0 $col_info->{'RDBO_DB_TYPE'} = $col_info->{'pg_type'};
651 }
652  
653 # We currently treat all arrays the same, regardless of what they are
654 # arrays of: integer, character, float, etc. So we covert TYPE_NAMEs
655 # like 'integer[]' into 'array'
656 0 ▶ if($col_info->{'TYPE_NAME'} =~ /^\w.*\[\]$/)
Branch: 1 branch
BranchTrueFalseTotal
if ($col_info->{"TYPE_NAME"} =~ /^\w.*\[\]$/) 0 0 0
657 {
658 0 $col_info->{'TYPE_NAME'} = 'array';
659 }
660  
661 0 return;
662 }
663  
664 sub parse_dbi_column_info_default
665 0 ▶{
Subroutine parse_dbi_column_info_default: not called CC=11 SCAR=46.8
Pod undocumented
666 0 my($self, $string, $col_info) = @_;
667  
668 17 ▶ no warnings 'uninitialized';
Subroutine BEGIN: called CC=1 SCAR=0.0
669 0 local $_ = $string;
670  
671 0 my $pg_vers = $self->dbh->{'pg_server_version'};
672  
673 # Example: q(B'00101'::"bit")
674 0 ▶ if(/^B'([01]+)'::(?:bit|"bit")$/ && $col_info->{'TYPE_NAME'} eq 'bit')
Branch: 4 branches
BranchTrueFalseTotal
if (/^B'([01]+)'::(?:bit|"bit")$/ and $col_info->{'TYPE_NAME'} eq 'bit') { } 0 0 0
elsif (/^(.+)::"?bigint"?$/i and $col_info->{'TYPE_NAME'} eq 'bigint') { } 0 0 0
elsif (/^\(*'(.*)'::.+$/) { } 0 0 0
elsif (/^nextval\(/) { } 0 0 0
Condition0%0/3
/^B'([01]+)'::(?:bit|"bit")$/ and $col_info->{"TYPE_NAME"} eq "bit"
!ll&&!rl&&r
000
MC/DC0%0/2
/^B'([01]+)'::(?:bit|"bit")$/ and $col_info->{"TYPE_NAME"} eq "bit"
/^B'([01]+)'::(?:bit|"bit")$/ $col_info->{"TYPE_NAME"} eq "bit"
Truth table0%0/3
A and B
A= /^B'([01]+)'::(?:bit|"bit")$/B= $col_info->{"TYPE_NAME"} eq "bit"
ABresult
0X0
100
111
675 {
676 0 return $1;
677 }
678 # Example: 922337203685::bigint
679 ▶ elsif(/^(.+)::"?bigint"?$/i && $col_info->{'TYPE_NAME'} eq 'bigint')
Condition0%0/3
/^(.+)::"?bigint"?$/i and $col_info->{"TYPE_NAME"} eq "bigint"
!ll&&!rl&&r
000
MC/DC0%0/2
/^(.+)::"?bigint"?$/i and $col_info->{"TYPE_NAME"} eq "bigint"
/^(.+)::"?bigint"?$/i $col_info->{"TYPE_NAME"} eq "bigint"
Truth table0%0/3
A and B
A= /^(.+)::"?bigint"?$/iB= $col_info->{"TYPE_NAME"} eq "bigint"
ABresult
0X0
100
111
680 {
681 0 return $1;
682 }
683 # TODO: http://rt.cpan.org/Ticket/Display.html?id=35462
684 # Example: '{foo,"\\"bar,",baz}'::text[]
685 # ...
686 # Example: 'value'::character varying
687 # Example: ('now'::text)::timestamp(0)
688 elsif(/^\(*'(.*)'::.+$/)
689 {
690 0 my $default = $1;
691  
692 # Single quotes are backslash-escaped, but PostgreSQL 8.1 and
693 # later uses doubled quotes '' instead. Strangely, I see
694 # doubled quotes in 8.0.x as well...
695 0 ▶ if($pg_vers >= 80000 && index($default, q('')) > 0)
Branch: 2 branches
BranchTrueFalseTotal
if ($pg_vers >= 80000 and index($default, q['']) > 0) { } 0 0 0
elsif ($pg_vers < 80100 and index($default, q[\\']) > 0) { } 0 0 0
Condition0%0/3
$pg_vers >= 80000 and index($default, "''") > 0
!ll&&!rl&&r
000
MC/DC0%0/2
$pg_vers >= 80000 and index($default, "''") > 0
$pg_vers >= 80000 index($default, "''") > 0
Truth table0%0/3
A and B
A= $pg_vers >= 80000B= index($default, "''") > 0
ABresult
0X0
100
111
696 {
697 0 $default =~ s/''/'/g;
698 }
699 ▶ elsif($pg_vers < 80100 && index($default, q(\')) > 0)
Condition0%0/3
$pg_vers < 80100 and index($default, "\\'") > 0
!ll&&!rl&&r
000
MC/DC0%0/2
$pg_vers < 80100 and index($default, "\\'") > 0
$pg_vers < 80100 index($default, "\\'") > 0
Truth table0%0/3
A and B
A= $pg_vers < 80100B= index($default, "\\'") > 0
ABresult
0X0
100
111
700 {
701 0 $default = $1;
702 0 $default =~ s/\\'/'/g;
703 }
704  
705 0 return $default;
706 }
707 # Handle sequence-based defaults elsewhere
708 elsif(/^nextval\(/)
709 {
710 0 return undef;
711 }
712  
713 0 return $string;
714 }
715  
716 sub refine_dbi_foreign_key_info
717 0 ▶{
Subroutine refine_dbi_foreign_key_info: not called CC=7 SCAR=40.3
Pod undocumented
718 0 my($self, $fk_info) = @_;
719  
720 0 $self->Rose::DB::refine_dbi_foreign_key_info($fk_info);
721  
722 0 ▶ if(!defined $DBD_PG_AFTER_380 && defined $DBD::Pg::VERSION)
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $Rose::DB::Pg::DBD_PG_AFTER_380 and defined $DBD::Pg::VERSION) 0 0 0
Condition0%0/3
not defined $Rose::DB::Pg::DBD_PG_AFTER_380 and defined $DBD::Pg::VERSION
!ll&&!rl&&r
000
MC/DC0%0/2
not defined $Rose::DB::Pg::DBD_PG_AFTER_380 and defined $DBD::Pg::VERSION
not defined $Rose::DB::Pg::DBD_PG_AFTER_380 defined $DBD::Pg::VERSION
Truth table0%0/3
not(A) and B
A= not defined $Rose::DB::Pg::DBD_PG_AFTER_380B= defined $DBD::Pg::VERSION
ABresult
0X0
100
111
723 {
724 0 ▶ $DBD_PG_AFTER_380 = ($DBD::Pg::VERSION =~ /^(\d+)\.(\d+)/ && ($1 >=3 && $2 >= 8)) ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$DBD::Pg::VERSION =~ /^(\d+)\.(\d+)/ && ($1 >= 3 && $2 >= 8) ? : 0 0 0
Condition0%0/6
$DBD::Pg::VERSION =~ /^(\d+)\.(\d+)/ and ($1 >= 3 and $2 >= 8)
!ll&&!rl&&r
000
$1 >= 3 and $2 >= 8
!ll&&!rl&&r
000
MC/DC0%0/3
$DBD::Pg::VERSION =~ /^(\d+)\.(\d+)/ and ($1 >= 3 and $2 >= 8)
$DBD::Pg::VERSION =~ /^(\d+)\.(\d+)/ $1 >= 3 $2 >= 8
Truth table0%0/4
A and B and C
A= $DBD::Pg::VERSION =~ /^(\d+)\.(\d+)/B= $1 >= 3C= $2 >= 8
ABCresult
0XX0
10X0
1100
1111
725 }
726  
727 0 ▶ if($DBD_PG_AFTER_380)
Branch: 1 branch
BranchTrueFalseTotal
if ($Rose::DB::Pg::DBD_PG_AFTER_380) 0 0 0
728 {
729 0 $fk_info->{'FK_TABLE_CAT'} = undef;
730 0 $fk_info->{'UK_TABLE_CAT'} = undef;
731 }
732 }
733  
734 sub list_tables
735 0 ▶{
Subroutine list_tables: not called CC=7 SCAR=40.3
Pod undocumented
736 0 my($self, %args) = @_;
737  
738 0 ▶ my $types = $args{'include_views'} ? "'TABLE','VIEW'" : 'TABLE';
Branch: 1 branch
BranchTrueFalseTotal
$args{'include_views'} ? : 0 0 0
739 0 my @tables;
740  
741 0 my $schema = $self->schema;
742 0 ▶ $schema = $self->default_implicit_schema unless(defined $schema);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $schema 0 0 0
743  
744 0 my $error;
745  
746 TRY:
747 {
748 0 local $@;
749  
750 eval
751 0 {
752 0 ▶ my $dbh = $self->dbh or die $self->error;
Branch: 1 branch
BranchTrueFalseTotal
my $dbh = $self->dbh or die $self->error 0 0 0
753  
754 0 local $dbh->{'RaiseError'} = 1;
755 0 local $dbh->{'FetchHashKeyName'} = 'NAME';
756  
757 0 my $sth = $dbh->table_info($self->catalog, $schema, '', $types,
758 { noprefix => 1, pg_noprefix => 1 });
759  
760 0 $sth->execute;
761  
762 0 ▶ while(my $table_info = $sth->fetchrow_hashref)
Branch: 1 branch
BranchTrueFalseTotal
if (my $table_info = $sth->fetchrow_hashref) 0 0 0
763 {
764 0 push(@tables, $self->unquote_table_name($table_info->{'TABLE_NAME'}));
765 }
766 };
767  
768 0 $error = $@;
769 }
770  
771 0 ▶ if($error)
Branch: 1 branch
BranchTrueFalseTotal
if ($error) 0 0 0
772 {
773 0 Carp::croak "Could not list tables from ", $self->dsn, " - $error";
774 }
775  
776 0 ▶ return wantarray ? @tables : \@tables;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 0 0
777 }
778  
779 # sub list_tables
780 # {
781 # my($self) = shift;
782 #
783 # my @tables;
784 #
785 # my $schema = $self->schema;
786 # $schema = $db->default_implicit_schema unless(defined $schema);
787 #
788 # if($DBD::Pg::VERSION >= 1.31)
789 # {
790 # @tables = $self->dbh->tables($self->catalog, $schema, '', 'TABLE',
791 # { noprefix => 1, pg_noprefix => 1 });
792 # }
793 # else
794 # {
795 # @tables = $dbh->tables;
796 # }
797 # }
798 #
799 # return wantarray ? @tables : \@tables;
800 # }
801  
802 17 1;
803  
804 __END__
↑ Summary DB/SQLite.pm »