Branch Coverage

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

line%coveragebranch
343100TFif (my $params = Params::Get::get_params(undef, @_))
344100TFif ($$params{"expires_in"} and not $$params{"cache_duration"})
372100TFif (scalar(@_) % 2 == 0) { }
50TFelsif (scalar @_ == 1 and ref $_[0] eq 'HASH') { }
0TFelsif (scalar @_ > 0) { }
519100TFif (scalar @_ == 1 and not ref $_[0]) { }
100TFelsif (my $params = Params::Get::get_params(undef, @_)) { }
52550TFif (not defined $class) { }
100TFelsif ($class eq __PACKAGE__) { }
100TFelsif (&Scalar::Util::blessed($class)) { }
5260TFif (scalar keys %args > 0)
54550TFif (defined $args{"logger"} and not &Scalar::Util::blessed($args{"logger"}))
549100TFunless ($args{"dsn"} or $defaults{"dsn"})
550100TFunless $args{"directory"} or $defaults{"directory"}
552100TFunless -d ($args{'directory'} || $defaults{'directory'})
557100TFif (defined $$src{"id"})
55950TFunless $$src{"id"} =~ /^[a-zA-Z_][a-zA-Z0-9_]*$/
586100TFif (my $logger = $$params{"logger"})
587100TFif (&Scalar::Util::blessed($logger)) { }
605100TFunless $c and $c->isa(__PACKAGE__)
610100TF$$self{'sep_char'} ? :
61850TFif $$self{$table}
624100TFif (my $dsn = $$self{'dsn'} || $defaults{'dsn'})
62550TFunless "DBI"->can("connect")
62850TFif ($dsn =~ /^dbi:SQLite:/i) { }
0TFelsif ($dsn =~ /^dbi:Pg:/i) { }
0TFelsif ($dsn =~ /^dbi:mysql:/i) { }
63650TFunless $dbh = "DBI"->connect($dsn, $$self{"username"}, $$self{"password"}, {"RaiseError", 1, "AutoCommit", 1})
64050TFif ($dialect eq "sqlite")
65750TFunless $dbname =~ /^[a-zA-Z0-9_.-]+$/ and not $dbname =~ /\.\./
664100TFif (-r $slurp_file)
66650TFunless "DBI"->can("connect")
673100TFif ($dbh) { }
50TFelsif ($self->_is_berkeley_db('File::Spec'->catfile($dir, "$dbname.db"))) { }
69250TFunless -r $candidate
6930TFunless &Database::Abstraction::open($fin, "<", $candidate)
69750TFif (defined $slurp_file and -r $slurp_file) { }
709100TFif (-r $psv and &Database::Abstraction::open($fin, '<', $psv)) { }
717100TFunless -r $candidate
71850TFunless &Database::Abstraction::open($fin, "<", $candidate)
724100TFif (my $filename = $$self{'filename'} || $defaults{'filename'})
72550TFunless $filename =~ /^[a-zA-Z0-9_.-]+$/ and not $filename =~ /\.\./
730100TFif (defined $slurp_file and -r $slurp_file) { }
731100TFif defined $fin
736100TFif ($$params{'column_names'}) { }
787100TFif (-s $slurp_file <= $max_slurp_size and not $$params{"column_names"})
78850TFif (-s $slurp_file == 0) { }
814100TFif ($$self{'no_entry'}) { }
819100TF@data ? :
829100TFif (-r $slurp_file) { }
830100TFif (-s $slurp_file <= $max_slurp_size) { }
838100TFif (ref $$xml{$key} eq 'ARRAY') { }
50TFelsif (ref $xml eq 'ARRAY') { }
100TFelsif (ref $xml eq 'HASH' and not $$self{'no_entry'}) { }
843100TFif (scalar keys %{$xml;} == 1) { }
844100TFif ($$xml{$table}) { }
856100TFif ($$self{'no_entry'}) { }
883100TFif $$self{"data"} and ref $$self{"data"} eq "HASH"
941100TFif ($$self{"berkeley"})
946100TFif ($$self{'no_entry'}) { }
100TFelsif (scalar @_) { }
957100TFif (my $join_spec = delete $params->{'join'})
961100TFif (not $join_clause and $$self{"data"} and not $self->_has_complex_criteria($params))
962100TFif (scalar keys %{$params;} == 0) { }
100TFelsif (scalar keys %{$params;} == 1 and defined $$params{'entry'} and not $$self{'no_entry'}) { }
50TFelsif (ref $$self{'data'} eq 'HASH') { }
964100TFif (ref $$self{"data"} eq "HASH")
96650TFif (scalar keys %{$$self{"data"};} <= 10)
977100TFunless exists $$self{"data"}{$$params{"entry"}}
98550TFexists $row->{$_} ? :
995100TFif $join_clause
996100TFif ($join_clause) { }
100TFelsif ($$self{'type'} eq 'CSV' and not $$self{'no_entry'}) { }
997100TFif $where
1001100TFif $where
1003100TFif $where
1005100TFunless ($$self{"no_entry"})
1009100TFif (defined $query_args[0]) { }
101750TFif ($c = $$self{'cache'}) { }
10190TFif (defined $query_args[0])
10230TFif (my $rc = $c->get($key))
103750TFif (my $sth = $$self{$table}->prepare_cached($query))
103850TFunless $sth->execute(@query_args)
104250TFif scalar keys %{$href;}
104450TFif $c
104650TFunless ($$self{"no_fixate"})
1095100TFif ($$self{"berkeley"})
109850TFwantarray ? :
1106100TFif (my $join_spec = delete $params->{'join'})
1110100TFif (not $join_clause and $$self{"data"} and not $self->_has_complex_criteria($params))
1111100TFif (scalar keys %{$params;} == 0) { }
100TFelsif (scalar keys %{$params;} == 1 and defined $$params{'entry'} and not $$self{'no_entry'}) { }
50TFelsif (ref $$self{'data'} eq 'HASH') { }
1113100TFif (ref $$self{"data"} eq "HASH")
1120100TFunless exists $$self{"data"}{$$params{"entry"}}
112750TFexists $row->{$_} ? :
1137100TFif $join_clause
1138100TFif ($join_clause) { }
100TFelsif ($$self{'type'} eq 'CSV' and not $$self{'no_entry'}) { }
113950TFif $where
114350TFif $where
1145100TFif $where
1147100TFunless ($$self{"no_entry"})
1150100TFunless (wantarray)
1154100TFif (defined $query_args[0]) { }
116250TFif ($c = $$self{'cache'}) { }
11640TFif (wantarray)
11670TFif (defined $query_args[0])
11710TFif (my $rc = $c->get($key))
11730TFwantarray ? :
118550TFif (my $sth = $$self{$table}->prepare_cached($query))
118650TFunless $sth->execute(@query_args)
1190100TFunless (wantarray)
119350TFif $c
119850TFif $c
120050TFif ($rc)
120150TFunless ($$self{"no_fixate"})
1244100TFif ($$self{"berkeley"})
1252100TFif ($$self{"data"})
1253100TFif (scalar keys %{$params;} == 0) { }
100TFelsif (scalar keys %{$params;} == 1 and defined $$params{'entry'} and not $$self{'no_entry'}) { }
1255100TFif (ref $$self{"data"} eq "HASH")
1261100TFexists $$self{'data'}{$$params{'entry'}} && $$self{'data'}{$$params{'entry'}} ? :
1269100TFif ($$self{'type'} eq 'CSV' and not $$self{'no_entry'}) { }
100TFelsif ($$self{'no_entry'}) { }
1272100TFif $where
1275100TFif $where
127850TFif $where
1281100TFif (defined $query_args[0]) { }
128950TFif ($c = $$self{'cache'}) { }
12960TFif (defined $query_args[0])
12990TFif (my $rc = $c->get($key))
13010TFref $rc eq 'ARRAY' ? :
130850TFif (my $sth = $$self{$table}->prepare_cached($query))
130950TFunless $sth->execute(@query_args)
1353100TFif (not $$self{'no_entry'}) { }
1362100TFif ($$self{"data"} and not $$self{"no_entry"} and scalar keys %{$params;} == 1 and defined $$params{"entry"} and not $self->_has_complex_criteria($params))
1365100TFexists $$self{'data'}{$$params{'entry'}} ? :
136850TFif ($$self{"berkeley"})
13710TFif (not $$self{"no_entry"} and scalar keys %{$params;} == 1 and defined $$params{"entry"})
13750TFif ($$self{"no_entry"} and scalar keys %{$params;} == 1 and defined $id and defined $$params{$id})
13760TFif (my $rc = $$self{"berkeley"}{$$params{$id}})
1386100TF$join_spec ? :
1391100TFif $join_clause
1392100TFif ($join_clause) { }
100TFelsif ($$self{'type'} eq 'CSV' and not $$self{'no_entry'}) { }
139350TFif $where
139750TFif $where
139950TFif $where
1402100TFif (defined $query_args[0]) { }
1410100TFif (defined $query_args[0]) { }
141150TFif (wantarray)
141950TFif ($c = $$self{"cache"})
14200TFif (my $rc = $c->get($key))
14210TFif (wantarray) { }
14220TFif (ref $rc eq "ARRAY")
143250TFunless my $sth = $$self{$table}->prepare_cached($query)
143350TFunless $sth->execute(@query_args)
143650TFif ($c)
14370TFif ($rc) { }
1475100TFif ($$self{"berkeley"})
148350TFunless defined $$args{"query"}
149050TFunless $query =~ /\sFROM\s/i
1499100TFif (exists $args->{'args'}) { }
1500100TFref $$args{'args'} eq 'ARRAY' ? :
150150TFunless $sth->execute(@bind)
150350TFunless $sth->execute
1509100TFunless (wantarray)
1560100TFif $$self{"_columns"}
1566100TFif ($$self{"berkeley"})
1570100TFif (my $data = $$self{'data'}) { }
157150TFif (ref $data eq "HASH")
157350TFif $first
1633100TFif $$self{"_schema"}
1638100TFif ($$self{"berkeley"})
1645100TFif (my $data = $$self{'data'}) { }
164650TFif (ref $data eq "HASH")
164850TFif ($first)
1651100TF$col eq $id ? :
100TF$col eq $id ? :
1662100TFif ($driver eq 'SQLite') { }
167650TFif ($sth)
177350TFif $column eq "DESTROY"
177550TFunless my $self = shift()
177750TFunless ref $self
1780100TFif exists $self->{'auto_load'} and not $$self{"auto_load"}
178350TFunless $column =~ /^[a-zA-Z_][a-zA-Z0-9_]*$/
1788100TFif (ref $_[0] eq 'HASH') { }
100TFelsif (scalar(@_) % 2 == 0) { }
50TFelsif (scalar @_ == 1) { }
179450TFif ($$self{"no_entry"} and not $$self{"berkeley"})
180050TFif ($$self{"berkeley"})
18010TFif (my $id = $$self{"id"})
180750TFunless defined $$self{"type"}
1812100TFif (wantarray and not $distinct) { }
1813100TFif (scalar keys %params == 0 and my $data = $$self{"data"})
1818100TFref $data eq 'ARRAY' ? :
1819100TFexists $_->{$column} ? :
1822100TFif ($$self{'type'} eq 'CSV' and not $$self{'no_entry'}) { }
1829100TFif (my $data = $$self{"data"})
1833100TFif ($$self{'no_entry'}) { }
100TFelsif (scalar keys %params == 1 and defined(my $key = $params{'entry'})) { }
100TFelsif (scalar keys %params == 0) { }
183650TFif (defined $key)
184050TFunless exists $row->{$key} and defined $$row{$key} and $$row{$key} eq $value
184150TFexists $row->{$column} ? :
184250TFdefined $rc ? :
1852100TFif (exists $data->{$key} and defined(my $hash = $$data{$key}))
1853100TFunless (exists $hash->{$column})
1858100TFif (defined $rc) { }
186550TFif (wantarray)
186650TFif ($distinct)
186750TFexists $_->{$column} ? :
18770TFexists $v->{$column} ? :
1883100TFunless exists $row->{$key} and defined $$row{$key} and $$row{$key} eq $value
188450TFunless exists $row->{$column}
188550TFif (my $rc = $$row{$column})
1895100TFif ($$self{'type'} eq 'CSV' and not $$self{'no_entry'}) { }
1906100TFunless $k =~ /^[a-zA-Z_][a-zA-Z0-9_.]*$/
1909100TFdefined $value ? :
1910100TFif (defined $value) { }
1911100TF$done_where ? :
191550TF$done_where ? :
1919100TFif (wantarray) { }
1924100TFif (scalar @args and $args[0]) { }
193150TFif ($cache = $$self{'cache'}) { }
19320TFif (wantarray)
19350TFif (defined $args[0]) { }
19400TFif (my $rc = $cache->get($key))
19420TFwantarray ? :
194950TFunless $sth->execute(@args)
1951100TFif (wantarray)
195350TFif ($cache)
195650TFunless $$self{"no_fixate"}
196150TFif ($cache)
197050TFif (defined $^V and $^V ge "v5.14.0")
197150TFif ${^GLOBAL_PHASE} eq "DESTRUCT"
1982100TFif (my $dbh = delete $self->{$table_name})
198350TFif $dbh->can("disconnect")
198450TFif $dbh->can("finish")
1988100TFif ($$self{"berkeley"})
2007100TFref $join_spec eq 'ARRAY' ? :
2013100TFunless my $jtable = $$j{"table"}
201450TFunless $jtable =~ /^[a-zA-Z_][a-zA-Z0-9_.]*$/
2016100TFunless my $on = $$j{"on"}
2017100TFunless $valid_types{$type}
2029100TFunless defined $params
2030100TFif exists $params->{'-or'} or exists $params->{'-and'}
2032100TFif ref $v
2049100TFif (my $or_list = delete $p{'-or'})
205350TFif ($s)
205850TFif (@sub_clauses)
2063100TFif (my $and_list = delete $p{'-and'})
206750TFif ($s)
207250TFif (@sub_clauses)
2079100TFif ($more)
2101100TFunless $col =~ /^[a-zA-Z_][a-zA-Z0-9_.]*$/
2104100TFif (ref $val eq 'HASH') { }
100TFelsif (ref $val) { }
100TFelsif (not defined $val) { }
100TFelsif ($val =~ /[%_]/) { }
2107100TFif ($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 =~ /^(?:>|<|>=|<=)$/) { }
2108100TF$op eq '-in' ? :
2122100TFif (not defined $operand) { }
216250TFif (delete $params->{'join'})
21650TFunless $_ eq "-or"
50TFif (grep {$_ eq "-and" unless $_ eq "-or";} keys %{$params;})
217250TFif (my(@cols) = keys %{$params;})
21770TFunless ($self->_match_criterion($$row{$col}, $$params{$col}))
2203100TFif ($p[$i - 1] eq '%') { }
2206100TF$dp[$i - 1][$j] || $dp[$i][$j - 1] ? :
2210100TF$dp[$i - 1][$j - 1] && ($p[$i - 1] eq '_' || $p[$i - 1] eq $s[$j - 1]) ? :
2222100TFif (ref $crit_val eq "HASH")
2225100TFif ($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 '<=') { }
2226100TFunless defined $row_val and grep {$row_val eq $_;} @{$operand;}
2228100TFif defined $row_val and grep {$row_val eq $_;} @{$operand;}
2230100TFunless defined $row_val and $row_val >= $$operand[0] and $row_val <= $$operand[1]
2232100TFunless defined $row_val
2233100TFunless _like_match($row_val, $operand)
2235100TFunless defined $row_val
223650TFif _like_match($row_val, $operand)
2238100TFif (not defined $operand) { }
2239100TFunless defined $row_val
2241100TFunless defined $row_val and $row_val ne $operand
2244100TFunless defined $row_val and $row_val > $operand
2246100TFunless defined $row_val and $row_val < $operand
2248100TFunless defined $row_val and $row_val >= $operand
2250100TFunless defined $row_val and $row_val <= $operand
2256100TF!(defined $row_val && defined $crit_val) ? :
100TF!(defined $row_val || defined $crit_val) ? :
2273100TFunless $$self{$table} or $$self{"data"} or $$self{"berkeley"}
228650TFif (my $dbh = $$self{$table})
2302100TFunless do {         BEGIN {     $^H{'autodie::Scope::GuardStack/guard4'} = 'autodie::Scope::Guard=CODE(0x55c21c3ec538)';     $^H{'no Fatal'} = 'HASH(0x55c21b7204a0)'; } open $fh, "<", $file }
230850TFif ($is_db)
23110TFif require DB_File
23140TFif (tie %bdb, "DB_File", $file, 0, 420, $DB_File::DB_HASH)
2330100TFunless &Database::Abstraction::read($fh, \my $magic_bytes, 4) == 4
235250TFunless &Database::Abstraction::seek($fh, 12, 0)
2353100TFunless &Database::Abstraction::read($fh, \$header, 4)
237150TFif (scalar @messages and my $logger = $$self{"logger"})