Branch Coverage

lib/DBIx/Oro.pm
Criterion Covered Total %
branch 312 498 62.6


line true false branch
102 0 0 unless (eval "require $module; 1;")
103 0 0 if croak(qq[Unable to load extension "$_"])
121 1 26 if (@_ == 1) { }
6 20 elsif (@_ == 2 and ref $_[1] and ref $_[1] eq 'CODE') { }
146 0 27 unless (eval 'require ' . $package . '; 1;')
158 0 27 unless $self
164 0 27 if $pwd
170 0 27 if ($on_connect)
171 0 0 ref $on_connect eq 'HASH' ? :
0 0 unless $self->on_connect(ref $on_connect eq 'HASH' ? %$on_connect : $on_connect)
178 0 27 unless $self->_connect
185 27 0 if $self->_init
199 3 23 if (ref $_[0]) { }
230 0 1431 if $_[0]
232 921 510 if ${$self->{'in_txn'};}
237 0 510 if (defined $self->{'tid'} and $self->{'tid'} != 'threads'->tid) { }
0 510 elsif ($self->{'pid'} != $$) { }
507 3 elsif ($self->{'dbh'}{'Active'}) { }
261 0 29 if ($last_sql =~ /(?:UNION|\?(?:, \?){3,}|(?:\(\?(?:, \?)*\), ){3,})/)
285 12 17 unless wantarray
288 1 16 unless $last_sql
316 0 0 unless my $table = _table_name($self, \@_)
319 0 0 unless $_[0]
322 0 0 if ref $_[0] eq 'HASH' and ref $_[1]
325 0 0 if (ref $_[0] eq 'HASH') { }
0 0 elsif (ref $_[0] eq 'ARRAY') { }
335 0 0 unless ref $key or $key =~ /$KEY_REGEX/
341 0 0 unless @keys
346 0 0 if ($prop and my $oc = $prop->{'-on_conflict'})
347 0 0 if ($oc eq 'replace') { }
0 0 elsif ($oc eq 'ignore') { }
365 0 0 unless $_[1]
378 0 0 unless ref $keys[$i]
413 0 25 unless my $table = _table_name($self, \@_)
416 0 25 unless $_[0]
422 0 25 unless @$pairs
426 1 24 unless $_ =~ /^$KEY_REGEX\s+(?:=|IS\s)/o
436 24 0 if ($_[0])
440 24 0 if (@$cond_pairs)
454 8 16 !$rv || $rv eq '0E0' ? :
472 38 87 if ($_[0] and ref $_[0] eq 'ARRAY')
475 0 38 if $fields->[0]
492 104 21 if ($_[0] and ref $_[0] eq 'HASH' or @$join_pairs)
496 104 0 if ($_[0] and ref $_[0] eq 'HASH')
502 93 11 if $pairs->[0]
506 94 10 if @pairs
509 63 41 if ($prep)
510 1 62 if delete $prep->{'distinct'}
521 0 63 if ($prep and $prep->{'cache'})
527 0 0 unless $key
534 1 124 if (scalar keys %$prep)
541 0 125 if ($result) { }
547 2 123 unless $sth
557 8 115 if ($treatment)
565 0 0 if ($_[0] and ref $_[0] and ref $_[0] eq 'CODE')
572 0 0 $sth ? :
575 0 0 if $chi and $sth
581 0 0 if ($treatment)
594 0 0 if ($rv and $rv eq '-1')
601 0 0 if ($sth and $chi and $result)
606 0 0 if not $sth and $chi
614 123 0 unless ($result)
618 0 123 if ($chi and $result)
624 115 8 unless $treatment
633 12 0 if $row->{$_}
647 1 20 if ref $_[-1] and ref $_[-1] eq 'CODE'
650 21 0 if ref $_[-1] and ref $_[-1] eq 'HASH'
653 19 2 if $_[0]
663 0 21 if $param->{'-cache'}
670 21 0 if ($sort_by and $sort_by =~ s/^\s*($KEY_REGEX)\s*$/$1/)
673 12 9 index(lc $param->{'sortOrder'}, 'desc') == 0 ? :
676 12 9 $sort_order ? :
680 12 9 if $sort_order
688 2 19 if ($start_page > 1)
701 21 0 if ($filter_by)
705 21 0 if ($filter_op)
713 4 17 if ($filter_op eq 'present') { }
1 16 elsif ($filter_op eq 'absent') { }
730 16 0 if (my $fv = _check_param($param, 'filterValue')) { }
736 1 15 if ($filter_op eq 'equals') { }
1 14 elsif ($filter_op eq 'disparate') { }
754 1 13 if ($filter_op eq 'contains') { }
13 0 elsif ($filter_op eq 'startswith') { }
780 1 20 unless defined $total_results
784 5 15 if ($param->{'fields'})
787 1 4 if (ref $param->{'fields'}) { }
803 20 0 if ($total_results)
806 2 18 if (ref $self->{'table'} and @fields) { }
3 15 elsif (@fields) { }
817 36 0 if exists $row->{$_}
839 1 19 if ($cb and @$entry)
865 29 0 if ($param[-1] and ref $param[-1]) { }
868 24 5 if (ref $param[-1] eq 'HASH') { }
0 5 elsif (ref $param[-1] ne 'ARRAY') { }
888 1 28 unless $row
900 0 11 unless my $table = _table_name($self, \@_)
907 5 6 if ($_[0])
913 5 0 if @$pairs or $prep
916 0 5 if $prep
923 4 7 !$rv || $rv eq '0E0' ? :
932 0 10 unless my $table = _table_name($self, \@_)
935 10 0 $_[0] ? :
939 9 1 unless $self->{'table'}
949 5 5 if $rv
953 2 4 if ref $cond{$_}
958 5 0 unless $self->{'table'}
960 1 4 unless $rv = $self->insert(@param)
965 1 9 unless $self->txn(sub { $rv = $self->update(@param); return 1 if $rv; delete $cond{$_} foreach (grep {not &blessed($cond{$_}) if ref $cond{$_};} keys %cond); @param = {%param, %cond}; unshift @param, $table unless $self->{'table'}; return -1 unless $rv = $self->insert(@param); $job = 'insert'; return; } )
968 9 0 if ($rv and $rv > 0)
969 9 0 wantarray ? :
992 1 51 if $_[0] and ref $_[0] eq 'ARRAY'
996 30 22 if ($_[0] and ref $_[0] eq 'HASH')
998 30 0 if $pairs->[0]
1002 30 22 if @pairs
1009 0 0 if ($prep and $prep->{'cache'})
1015 0 0 unless $key
1018 0 0 if ($result = $chi->get($key))
1032 3 49 unless $rv
1039 0 49 if $chi and $result
1055 0 1189 $cached ? :
1060 11 1178 if ($dbh->err)
1062 11 0 if (index($dbh->errstr, 'database') <= 0)
1070 0 0 $cached ? :
1074 0 0 if ($dbh->err)
1081 0 1178 unless $sth
1087 4 1174 if ($dbh->err)
1093 203 971 if wantarray
1113 0 126 if not $rv and $dbh->err
1129 0 69 unless $_[0] and ref $_[0] eq 'CODE'
1134 67 2 if ($dbh->{'AutoCommit'}) { }
1144 65 2 if (not $rv or $rv ne '-1')
1167 0 2 if $self->{'tid'}
1182 2 0 if ($last_sp eq $sp) { }
1192 1 1 if (not $rv or $rv ne '-1')
1210 0 3 unless ref $cb and ref $cb eq 'CODE'
1215 2 1 unless (exists $self->{'on_connect'}{$name})
1228 0 0 unless @_
1240 0 0 if ref $_[-1] and ref $_[-1] eq 'CODE'
1242 0 0 @_ > 1 ? :
1244 0 0 unless $files
1251 0 0 unless $file
1253 0 0 if (open SQL, '<:utf8', $file) { }
1266 0 0 if $cb and $sql
1268 0 0 unless $sql
1272 0 0 unless $self->do($_)
1287 0 0 if (ref $files)
1291 0 0 unless &$import($_)
1306 10 26 unless (exists $self->{'table'})
1309 0 10 unless $self->{'dbh'}
1315 10 0 if (&blessed($self->{'dbh'}))
1318 0 10 if $kids
1342 0 30 unless $self->{'dsn'}
1357 0 30 unless $dbh
1366 0 30 if $INC{'threads.pm'}
1391 0 40 if index('DBIx::Oro', $this) != 0
1394 30 10 unless (defined $pwd_set)
1399 0 10 if ($pwd_set) { }
1408 0 0 unless /::new$/o
1409 0 0 unless index($_, 'DBIx::Oro') == 0
1410 0 0 if $pwd{$id}
1424 18 966 if (exists $self->{'table'}) { }
1425 966 0 unless ref $_[0][0]
1432 18 0 unless ref $self->{'table'}
1447 53 124 if (exists $self->{'table'}) { }
1452 10 114 if (ref $table) { }
1466 8 45 if (ref $self->{'table'}) { }
1495 2 24 if $table =~ s/^([^:]+?):([^:]+?)$/$1 $2/o
1501 2 24 $t_alias ? :
1503 26 0 if (my $ref = ref $join[0])
1509 22 4 if ($ref eq 'ARRAY') { }
1516 22 0 if (ref $join[0] and ref $join[0] eq 'HASH')
1520 1 21 if (exists $join[0]{'-prefix'})
1522 1 0 if $f_prefix eq '*'
1531 33 0 unless (ref $_)
1534 24 9 if (index($_, ':') == -1)
1539 32 1 if (index($_, '(') == -1) { }
1540 31 1 if index($_, '.') == -1
1566 21 1 if $fields
1575 26 0 if (ref $join[0] and ref $join[0] eq 'HASH')
1582 0 26 if ($alias{$key}) { }
1583 26 0 if $key =~ /$KEY_REGEX_NOPREF/
1590 2 24 ref $value ? :
1605 1 13 $ind < 0 ? :
1622 142 55 @_ == 2 ? :
1627 0 307 unless ($key =~ /^-?$KEY_REGEX$/o)
1628 0 0 if carp("$key is not a valid Oro key")
1632 195 112 if (substr($key, 0, 1) ne '-') { }
1635 1 186 index($key, '.') >= 0 ? :
8 187 exists $alias->{$key} ? :
1638 3 0 do { $value = _stringify($value) } ? :
1 3 do { ref $value eq 'SCALAR' } ? :
84 4 do { ref $value eq 'HASH' } ? :
7 88 do { ref $value eq 'ARRAY' } ? :
95 100 ref $value ? :
1641 97 3 if (defined $value) { }
1656 1 6 if (ref $value->[0] and ref $value->[0] eq 'SCALAR')
1671 86 0 if ($op =~ /$OP_REGEX/) { }
1681 24 62 if $_ =~ /^(?:[GL][TE]|NE|EQ)$/o
1686 3 83 if (ref $val and ref $val eq 'ARRAY') { }
1689 2 1 if (index($op, 'BETWEEN') >= 0) { }
1 0 elsif ($op =~ /^NOT( IN)?$/) { }
1709 0 83 if (&blessed($val))
1710 0 0 unless $val = _stringify($val)
1715 75 8 if (defined $val) { }
1726 29 54 if ($op eq 'LIKE')
1737 0 0 if carp("Unknown Oro operator $key $op $val")
1756 0 0 $value ? :
0 0 if carp("Unknown Oro pair $key, " . ($value ? $value : '[undef]'))
1765 0 112 unless defined $value
1768 70 42 if ($key =~ /^-(?:limit|offset|distinct)$/) { }
38 4 elsif ($key =~ s/^-(order|group)(?:[-_]by)?$/$1/) { }
4 0 elsif ($key =~ /^-(or|and)$/) { }
0 0 elsif ($key eq '-cache') { }
1769 70 0 if $value =~ /^\d+$/o
1776 2 36 if ($key eq 'group' and ref $value)
1777 1 1 if (ref $value->[-1] and ref $value->[-1] eq 'HASH')
1780 0 1 unless (@$value)
1781 0 0 if carp('"Having" without "Group" is not allowed')
1789 3 35 ref $value ? :
1792 38 1 if ($_ =~ /$VALID_GROUPORDER_REGEX/) { }
1794 17 21 $1 && $1 eq '-' ? :
1803 37 1 if scalar @field_array
1815 4 4 unless (ref $array[0])
1828 2 6 if (@$or_pairs > 1) { }
1847 0 0 if ($chi) { }
1862 63 134 keys %prep ? :
1875 12 72 ref $_ ? :
1878 71 1 if ($_ =~ /$VALID_FIELD_REGEX/) { }
1902 19 41 unless $fields =~ /[\.:=]/o
1910 53 8 if ($_ =~ /$FIELD_REST_RE/) { }
0 8 elsif (/^(?:.+?)\.(?:[^\.]+?)$/) { }
8 33 %treatment ? :
1943 3 60 if ($prep->{'group'})
1947 1 2 if ($prep->{'having'})
1955 1 0 if (@$cond_pairs)
1967 34 29 if (exists $prep->{'order'})
1972 47 16 if ($prep->{'limit'})
1977 21 26 if (defined $prep->{'offset'})
1989 20 3 unless my $ref = &blessed($_[0])
1990 3 0 if (index($_ = "$_[0]", $ref) != 0)
2009 98 44 if ($_[0]{$_[1]} and not ref $_[0]{$_[1]})
2012 19 79 if ($_[2])
2013 19 0 $_[0]{$_[1]} =~ /$NUM_RE/ ? :
2034 1448 5 unless (ref $r)
2041 1 4 if (ref $r eq 'SCALAR') { }
1 3 elsif (ref $r eq 'ARRAY') { }
2050 0 1 unless (ref $r->[0])
2064 3 0 if $s .= '?,'
2080 15 0 if length $last_sql <= 500