Branch Coverage

File:blib/lib/Database/Abstraction.pm
Coverage:72.0%

line%coveragebranch
378100TFif (my $params = Params::Get::get_params(undef, @_))
379100TFif ($$params{"expires_in"} and not $$params{"cache_duration"})
40750TFif (scalar @_ == 0 and ref $pkg eq 'HASH') { }
100TFelsif (scalar(@_) % 2 == 0) { }
50TFelsif (scalar @_ == 1 and ref $_[0] eq 'HASH') { }
0TFelsif (scalar @_ > 0) { }
591100TFif (scalar @_ == 1 and not ref $_[0]) { }
100TFelsif (my $params = Params::Get::get_params(undef, @_)) { }
59750TFif (not defined $class) { }
100TFelsif ($class eq __PACKAGE__) { }
100TFelsif (&Scalar::Util::blessed($class)) { }
5980TFif (scalar keys %args > 0)
612100TFif (defined $args{"id"})
61450TFunless $args{"id"} =~ /$SAFE_IDENTIFIER/
616100TFif (defined $args{"table"})
61850TFunless $args{"table"} =~ /$SAFE_QUALIFIED/
62850TFif (defined $args{"logger"} and not &Scalar::Util::blessed($args{"logger"}))
632100TFunless ($args{"dsn"} or $defaults{"dsn"} or $args{"url"} or $defaults{"url"})
633100TFunless $args{"directory"} or $defaults{"directory"}
638100TFunless ($given_host and not $class->_is_local_host($given_host))
639100TFunless -d ($args{'directory'} || $defaults{'directory'})
645100TFif (defined $$src{"id"})
647100TFunless $$src{"id"} =~ /$SAFE_IDENTIFIER/
649100TFif (defined $$src{"host"})
651100TFunless $$src{"host"} =~ /\A                                    (?:                   # optional "user\@" prefix                                            [a-zA-Z0-9]       # username: first char must be alnum                                            [a-zA-Z0-9._-]*   # username: rest may include dots and hyphens                                            \@                # literal at-sign; \@ prevents array interpolation                                    )?                                    [a-zA-Z0-9:]          # first char of host or IP; colon allows IPv6                                    [a-zA-Z0-9._:-]*      # rest: hostname, dotted IPv4, or IPv6 hex groups                            \z/x
661100TFif (defined $$src{"url"})
663100TFunless $$src{"url"} =~ m[\Ahttps?://]i
665100TFif (defined $$src{"table"})
667100TFunless $$src{"table"} =~ /$SAFE_QUALIFIED/
694100TFif (my $logger = $$params{"logger"})
695100TFif (&Scalar::Util::blessed($logger)) { }
71350TFunless $c and $c->isa(__PACKAGE__)
718100TF$$self{'sep_char'} ? :
72650TFif $$self{$table}
73250TFif (my $dsn = $$self{'dsn'} || $defaults{'dsn'})
7340TFif ($dsn =~ /^dbi:SQLite:/i) { }
0TFelsif ($dsn =~ /^dbi:Pg:/i) { }
0TFelsif ($dsn =~ /^dbi:mysql:/i) { }
7420TFunless $dbh = "DBI"->connect($dsn, $$self{"username"}, $$self{"password"}, {"RaiseError", 1, "AutoCommit", 1})
7460TFif ($dialect eq "sqlite")
76350TFif (my $url = $$self{'url'} || $defaults{'url'})
7700TFunless $response->is_success
7780TFunless @tables
7800TFif $tidx >= @tables
7840TFunless @rows
7870TFdefined $_ ? :
7900TFif ($$self{'no_entry'}) { }
7940TFdefined $_ ? :
8020TFdefined $_ ? :
8040TFunless defined $key
8120TFif $$self{"data"} and ref $$self{"data"} eq "HASH"
82550TFunless $dbname =~ /\A[a-zA-Z0-9_.-]+\z/ and not $dbname =~ /\.\./
83250TFif (my $host = $$self{'host'} || $defaults{'host'}) { }
8330TFif ($self->_is_local_host($host)) { }
8450TFunless defined $content and length $content
86750TFif (-r $candidate)
87050TFunless ($deep_file)
87250TFif -r $db_candidate and $self->_is_deep_db($db_candidate)
87650TFif (-r $slurp_file)
88350TFif ($dbh) { }
50TFelsif ($deep_file) { }
50TFelsif ($self->_is_berkeley_db('File::Spec'->catfile($dir, "$dbname.db"))) { }
8980TFif ($$self{'no_entry'}) { }
9060TF(&Scalar::Util::reftype($row) // '') eq 'HASH' ? :
9090TF@data ? :
9180TF(&Scalar::Util::reftype($row) // '') eq 'HASH' ? :
9210TF%data ? :
93750TFunless -r $candidate
94250TFif ($gz_file) { }
953100TFif (-r $psv) { }
962100TFunless -r $candidate
969100TFif (my $filename = $$self{'filename'} || $defaults{'filename'})
97050TFunless $filename =~ /\A[a-zA-Z0-9_.-]+\z/ and not $filename =~ /\.\./
975100TFif (defined $slurp_file and -r $slurp_file) { }
976100TFif defined $fin
981100TFif ($$params{'column_names'}) { }
1032100TFif (-s $slurp_file <= $max_slurp_size and not $$params{"column_names"})
103350TFif (-s $slurp_file == 0) { }
1059100TFif defined $$_{$id_col}
1061100TFif ($$self{'no_entry'}) { }
106650TF@data ? :
107650TFif (-r $xlsx_file) { }
10800TFunless $dbh = "DBI"->connect("dbi:Excel:file=$xlsx_file", undef, undef, {"RaiseError", 1, "PrintError", 0})
1088100TFif (-r $slurp_file) { }
108950TFif (-s $slurp_file <= $max_slurp_size) { }
109650TFif (ref $$xml{$key} eq 'ARRAY') { }
0TFelsif (ref $xml eq 'ARRAY') { }
0TFelsif (ref $xml eq 'HASH' and not $$self{'no_entry'}) { }
11010TFif (scalar keys %{$xml;} == 1) { }
11020TFif ($$xml{$table}) { }
111350TFif ($$self{'no_entry'}) { }
1141100TFif $$self{"data"} and ref $$self{"data"} eq "HASH"
1199100TFif ($$self{"berkeley"})
1204100TFif ($$self{'no_entry'}) { }
100TFelsif (scalar @_) { }
1215100TFif (my $join_spec = delete $params->{'join'})
1219100TFif (not $join_clause and $$self{"data"} and not $self->_has_complex_criteria($params))
1220100TFif (scalar keys %{$params;} == 0) { }
100TFelsif (scalar keys %{$params;} == 1 and defined $$params{'entry'} and not $$self{'no_entry'}) { }
50TFelsif (ref $$self{'data'} eq 'HASH') { }
1222100TFif (ref $$self{"data"} eq "HASH")
122450TFif (scalar keys %{$$self{"data"};} <= 10)
1235100TFunless exists $$self{"data"}{$$params{"entry"}}
124650TFexists $row->{$_} ? :
1256100TFif $join_clause
1257100TFif ($join_clause) { }
100TFelsif ($$self{'type'} eq 'CSV' and not $$self{'no_entry'}) { }
1258100TFif $where
1262100TFif $where
1264100TFif $where
1266100TFunless ($$self{"no_entry"})
1270100TFif (defined $query_args[0]) { }
127850TFif ($c = $$self{'cache'}) { }
12800TFif (defined $query_args[0])
12840TFif (my $rc = $c->get($key))
129850TFif (my $sth = $$self{$table}->prepare_cached($query))
129950TFunless $sth->execute(@query_args)
130350TFif %{$href;}
130550TFif $c
1307100TFif ($rc and not $$self{"no_fixate"})
1351100TFif ($$self{"berkeley"})
1354100TFwantarray ? :
1362100TFif (my $join_spec = delete $params->{'join'})
1366100TFif (not $join_clause and $$self{"data"} and not $self->_has_complex_criteria($params))
1367100TFif (scalar keys %{$params;} == 0) { }
100TFelsif (scalar keys %{$params;} == 1 and defined $$params{'entry'} and not $$self{'no_entry'}) { }
50TFelsif (ref $$self{'data'} eq 'HASH') { }
1369100TFif (ref $$self{"data"} eq "HASH")
1376100TFunless exists $$self{"data"}{$$params{"entry"}}
138650TFexists $row->{$_} ? :
1396100TFif $join_clause
1397100TFif ($join_clause) { }
100TFelsif ($$self{'type'} eq 'CSV' and not $$self{'no_entry'}) { }
139850TFif $where
1402100TFif $where
1404100TFif $where
1406100TFunless ($$self{"no_entry"})
1409100TFunless (wantarray)
1413100TFif (defined $query_args[0]) { }
142150TFif ($c = $$self{'cache'}) { }
14230TFif (wantarray)
14260TFif (defined $query_args[0])
14300TFif (my $rc = $c->get($key))
14320TFwantarray ? :
144450TFif (my $sth = $$self{$table}->prepare_cached($query))
144550TFunless $sth->execute(@query_args)
1449100TFunless (wantarray)
145250TFif $c
145750TFif $c
145950TFif ($rc)
146050TFunless ($$self{"no_fixate"})
1502100TFif ($$self{"berkeley"})
1510100TFif ($$self{"data"})
1511100TFif (scalar keys %{$params;} == 0) { }
100TFelsif (scalar keys %{$params;} == 1 and defined $$params{'entry'} and not $$self{'no_entry'}) { }
50TFelsif (not $self->_has_complex_criteria($params) || $$self{$table}) { }
1513100TFif (ref $$self{"data"} eq "HASH")
1519100TFexists $$self{'data'}{$$params{'entry'}} && $$self{'data'}{$$params{'entry'}} ? :
15320TFexists $row->{$_} ? :
15330TFref $$self{'data'} eq 'HASH' ? :
1541100TFif ($$self{'type'} eq 'CSV' and not $$self{'no_entry'}) { }
100TFelsif ($$self{'no_entry'}) { }
1544100TFif $where
1547100TFif $where
155050TFif $where
1553100TFif (defined $query_args[0]) { }
156150TFif ($c = $$self{'cache'}) { }
15710TFif (defined $query_args[0])
15740TFif (my $rc = $c->get($key))
15760TFref $rc eq 'ARRAY' ? :
158350TFif (my $sth = $$self{$table}->prepare_cached($query))
158450TFunless $sth->execute(@query_args)
1628100TFif (not $$self{'no_entry'}) { }
1637100TFif ($$self{"data"} and not $$self{"no_entry"} and scalar keys %{$params;} == 1 and defined $$params{"entry"} and not $self->_has_complex_criteria($params))
1640100TFexists $$self{'data'}{$$params{'entry'}} ? :
1643100TFif ($$self{"berkeley"})
164650TFif (not $$self{"no_entry"} and scalar keys %{$params;} == 1 and defined $$params{"entry"})
16500TFif ($$self{"no_entry"} and scalar keys %{$params;} == 1 and defined $id and defined $$params{$id})
16510TFif (my $rc = $$self{"berkeley"}{$$params{$id}})
1661100TF$join_spec ? :
1666100TFif $join_clause
1667100TFif ($join_clause) { }
100TFelsif ($$self{'type'} eq 'CSV' and not $$self{'no_entry'}) { }
166850TFif $where
167250TFif $where
167450TFif $where
1677100TFif (defined $query_args[0]) { }
1689100TFif (defined $query_args[0]) { }
169050TFif (wantarray)
169850TFif ($c = $$self{"cache"})
16990TFif (my $rc = $c->get($key))
17000TFif (wantarray) { }
17010TFif (ref $rc eq "ARRAY")
171150TFunless my $sth = $$self{$table}->prepare_cached($query)
171250TFunless $sth->execute(@query_args)
171550TFif ($c)
17160TFif ($rc) { }
1754100TFif ($$self{"berkeley"})
176250TFunless defined $$args{"query"}
177150TFunless $query =~ /\bFROM\b/i
1780100TFif (exists $args->{'args'}) { }
1781100TFref $$args{'args'} eq 'ARRAY' ? :
178250TFunless $sth->execute(@bind)
178450TFunless $sth->execute
1790100TFunless (wantarray)
1841100TFif $$self{"_columns"}
1847100TFif ($$self{"berkeley"})
1851100TFif (my $data = $$self{'data'}) { }
1852100TFif (ref $data eq 'HASH') { }
50TFelsif (ref $data eq 'ARRAY' and @{$data;}) { }
185450TFif $first
1916100TFif $$self{"_schema"}
1921100TFif ($$self{"berkeley"})
1928100TFif (my $data = $$self{'data'}) { }
1930100TFif (ref $data eq 'HASH') { }
50TFelsif (ref $data eq 'ARRAY' and @{$data;}) { }
193550TFif ($first)
1938100TF$col eq $id ? :
100TF$col eq $id ? :
1948100TFif ($driver eq 'SQLite') { }
196250TFif ($sth)
205950TFif $column eq "DESTROY"
2060100TFif $column =~ /\A_/
206250TFunless my $self = shift()
206450TFunless ref $self
2067100TFif exists $self->{'auto_load'} and not $$self{"auto_load"}
207050TFunless $column =~ /$SAFE_IDENTIFIER/
2075100TFif (ref $_[0] eq 'HASH') { }
100TFelsif (scalar(@_) % 2 == 0) { }
50TFelsif (scalar @_ == 1) { }
208150TFif ($$self{"no_entry"} and not $$self{"berkeley"})
208750TFif ($$self{"berkeley"})
20880TFif (my $id = $$self{"id"})
209450TFunless defined $$self{"type"}
2099100TFif (wantarray and not $distinct) { }
2100100TFif (scalar keys %params == 0 and my $data = $$self{"data"})
2105100TFref $data eq 'ARRAY' ? :
2106100TFexists $_->{$column} ? :
2109100TFif ($$self{'type'} eq 'CSV' and not $$self{'no_entry'}) { }
2116100TFif (my $data = $$self{"data"})
2120100TFif ($$self{'no_entry'}) { }
100TFelsif (scalar keys %params == 1 and defined(my $key = $params{'entry'})) { }
100TFelsif (scalar keys %params == 0) { }
212350TFif (defined $key)
2127100TFunless exists $row->{$key} and defined $$row{$key} and $$row{$key} eq $value
212850TFexists $row->{$column} ? :
212950TFdefined $rc ? :
2139100TFif (exists $data->{$key} and defined(my $hash = $$data{$key}))
2140100TFunless (exists $hash->{$column})
2145100TFif (defined $rc) { }
215250TFif (wantarray)
215350TFif ($distinct)
215850TFexists $r->{$column} ? :
2159100TFif defined $v
21700TFexists $v->{$column} ? :
2176100TFunless exists $row->{$key} and defined $$row{$key} and $$row{$key} eq $value
217750TFunless exists $row->{$column}
217850TFif (my $rc = $$row{$column})
2188100TFif ($$self{'type'} eq 'CSV' and not $$self{'no_entry'}) { }
2199100TFunless $k =~ /$SAFE_QUALIFIED/
2202100TFdefined $value ? :
2203100TFif (defined $value) { }
2204100TF$done_where ? :
220850TF$done_where ? :
2212100TFif (wantarray) { }
2217100TFif (scalar @args and $args[0]) { }
222450TFif ($cache = $$self{'cache'}) { }
22250TFif (wantarray)
22280TFif (defined $args[0]) { }
22330TFif (my $rc = $cache->get($key))
22350TFwantarray ? :
224250TFunless $sth->execute(@args)
2244100TFif (wantarray)
224850TFif ($cache)
225150TFif scalar @rc and not $$self{"no_fixate"}
225650TFif ($cache)
226550TFif (defined $^V and $^V ge "v5.14.0")
226650TFif ${^GLOBAL_PHASE} eq "DESTRUCT"
2273100TFif (defined $$self{"_temp_fh"})
2278100TFif defined $temp_path and -f $temp_path
2286100TFif (my $dbh = delete $self->{$table_name})
228750TFif $dbh->can("disconnect")
228850TFif $dbh->can("finish")
2292100TFif ($$self{"berkeley"})
2311100TFref $join_spec eq 'ARRAY' ? :
2316100TFunless my $jtable = $$j{"table"}
2317100TFunless $jtable =~ /$SAFE_QUALIFIED/
2319100TFunless my $on = $$j{"on"}
2320100TFunless $VALID_JOIN_TYPES{$type}
2332100TFunless defined $params
2333100TFif exists $params->{'-or'} or exists $params->{'-and'}
2335100TFif ref $v
2388100TFif (defined $or_list or defined $and_list) { }
2396100TFif ($or_list)
240050TFif ($s)
2405100TFif (@sub_clauses)
2410100TFif ($and_list)
241450TFif ($s)
241950TFif (@sub_clauses)
2426100TFif ($more)
2448100TFunless $col =~ /$SAFE_QUALIFIED/
2451100TFif (ref $val eq 'HASH') { }
100TFelsif (ref $val) { }
100TFelsif (not defined $val) { }
100TFelsif ($val =~ /[%_]/) { }
2454100TFif ($op eq '-in' or $op eq '-not_in') { }
100TFelsif ($op eq '-between') { }
100TFelsif ($op eq '-like') { }
100TFelsif ($op eq '-not_like') { }
100TFelsif ($op eq '!=') { }
100TFelsif ($op =~ /\A[<>]=?\z/) { }
2455100TF$op eq '-in' ? :
2469100TFif (not defined $operand) { }
2516100TFif (delete $params->{'join'})
2519100TFunless $_ eq "-or"
100TFif (grep {$_ eq "-and" unless $_ eq "-or";} keys %{$params;})
2527100TFif (@cols) { }
2534100TFunless ($self->_match_criterion($$row{$col}, $$params{$col}))
2539100TFif $match
2566100TFif $pattern eq "%"
2574100TFif index($lc_pat, "%") == -1 and index($lc_pat, "_") == -1
2579100TFif (index($lc_pat, "_") == -1)
2584100TFif ($first_pct == 0 and $last_pct == 0)
2592100TFif ($last_pct == $pat_len - 1 and $first_pct == $pat_len - 1)
2601100TFif ($first_pct == 0 and $last_pct == $pat_len - 1 and $pat_len >= 3)
2603100TFif (index($needle, "%") == -1)
2622100TFif ($pc eq '%') { }
2625100TF$$prev[$j] || $$curr[$j - 1] ? :
2629100TF$$prev[$j - 1] && ($pc eq '_' || $pc eq substr($lc_str, $j - 1, 1)) ? :
2642100TFif (ref $crit_val eq "HASH")
2645100TFif ($op eq '-in') { }
100TFelsif ($op eq '-not_in') { }
100TFelsif ($op eq '-between') { }
100TFelsif ($op eq '-like') { }
100TFelsif ($op eq '-not_like') { }
100TFelsif ($op eq '!=') { }
100TFelsif ($op eq '>') { }
100TFelsif ($op eq '<') { }
100TFelsif ($op eq '>=') { }
50TFelsif ($op eq '<=') { }
2646100TFunless defined $row_val and grep {$row_val eq $_;} @{$operand;}
2648100TFif defined $row_val and grep {$row_val eq $_;} @{$operand;}
2650100TFunless defined $row_val and $row_val >= $$operand[0] and $row_val <= $$operand[1]
2652100TFunless defined $row_val
2653100TFunless _like_match($row_val, $operand)
2655100TFunless defined $row_val
2656100TFif _like_match($row_val, $operand)
2658100TFif (not defined $operand) { }
2659100TFunless defined $row_val
2661100TFunless defined $row_val and $row_val ne $operand
2664100TFunless defined $row_val and $row_val > $operand
2666100TFunless defined $row_val and $row_val < $operand
2668100TFunless defined $row_val and $row_val >= $operand
2670100TFunless defined $row_val and $row_val <= $operand
2676100TF!(defined $row_val && defined $crit_val) ? :
100TF!(defined $row_val || defined $crit_val) ? :
2690100TFif ($$params{'table'}) { }
2703100TFunless $$self{$table} or $$self{"data"} or $$self{"berkeley"}
2716100TFif (my $dbh = $$self{$table})
2731100TFunless do {         BEGIN {     $^H{'autodie::Scope::GuardStack/guard5'} = 'autodie::Scope::Guard=CODE(0x561bad109b50)';     $^H{'no Fatal'} = 'HASH(0x561bad109ad8)'; } open $fh, "<", $file }
273750TFif ($is_db)
27430TFif (tie %bdb, "DB_File", $file, 0, 420, $DB_File::DB_HASH)
2758100TFunless &Database::Abstraction::read($fh, \my $buf, 4) == 4
2760100TFif $magic{unpack "N", $buf} or $magic{unpack "V", $buf}
276350TFunless &Database::Abstraction::seek($fh, 12, 0)
2764100TFunless &Database::Abstraction::read($fh, \$buf, 4)
2780100TFif $bare =~ /\A(?:localhost|127\.0\.0\.1|::1)\z/i
2785100TFif $lc_bare eq $me
2801100TFunless do {         BEGIN {     $^H{'autodie::Scope::GuardStack/guard6'} = 'autodie::Scope::Guard=CODE(0x561bad11af98)';     $^H{'no Fatal'} = 'HASH(0x561bad11af38)'; } open $fh, "<", $file }
2805100TFunless defined $n and $n == 4
282050TFif (scalar @messages and my $logger = $$self{"logger"})