Branch Coverage

lib/DBIx/Oro.pm
Criterion Covered Total %
branch 317 504 62.9


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 1430 if $_[0]
232 921 509 if ${$self->{'in_txn'};}
237 0 509 if (defined $self->{'tid'} and $self->{'tid'} != 'threads'->tid) { }
0 509 elsif ($self->{'pid'} != $$) { }
506 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 25 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 37 87 if ($_[0] and ref $_[0] eq 'ARRAY')
475 0 37 if $fields->[0]
492 103 21 if ($_[0] and ref $_[0] eq 'HASH' or @$join_pairs)
496 103 0 if ($_[0] and ref $_[0] eq 'HASH')
502 92 11 if $pairs->[0]
506 93 10 if @pairs
509 62 41 if ($prep)
510 1 61 if delete $prep->{'distinct'}
521 0 62 if ($prep and $prep->{'cache'})
527 0 0 unless $key
534 1 123 if (scalar keys %$prep)
541 124 0 if (not $result) { }
547 2 122 unless $sth
557 7 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 122 0 unless ($result)
618 0 122 if ($chi and $result)
624 115 7 unless $treatment
633 11 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 1188 $cached ? :
1060 11 1177 if ($dbh->err)
1062 11 0 if (index($dbh->errstr, 'database') <= 0)
1070 0 0 $cached ? :
1074 0 0 if ($dbh->err)
1081 0 1177 unless $sth
1087 4 1173 if ($dbh->err)
1093 202 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 10 0 if (not $pwd_set) { }
1408 0 0 unless /::new$/o
1409 0 0 unless index($_, 'DBIx::Oro') == 0
1410 0 0 if $pwd{$id}
1424 966 18 if (not exists $self->{'table'}) { }
1425 966 0 unless ref $_[0][0]
1432 18 0 unless ref $self->{'table'}
1447 123 53 if (not exists $self->{'table'}) { }
1452 113 10 if (not 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 26 0 if (not $alias{$key}) { }
1583 26 0 if $key =~ /$KEY_REGEX_NOPREF/
1590 2 24 ref $value ? :
1605 1 13 $ind < 0 ? :
1622 141 55 @_ == 2 ? :
1627 0 305 unless ($key =~ /^-?$KEY_REGEX$/o)
1628 0 0 if carp("$key is not a valid Oro key")
1632 194 111 if (substr($key, 0, 1) ne '-') { }
1635 1 185 index($key, '.') >= 0 ? :
8 186 exists $alias->{$key} ? :
1638 100 94 if (not ref $value) { }
7 87 elsif (ref $value eq 'ARRAY') { }
83 4 elsif (ref $value eq 'HASH') { }
1 3 elsif (ref $value eq 'SCALAR') { }
3 0 elsif ($value = _stringify($value)) { }
1641 3 97 if (not defined $value) { }
1657 1 6 if (ref $value->[0] and ref $value->[0] eq 'SCALAR')
1672 85 0 if ($op =~ /$OP_REGEX/) { }
1682 24 61 if $_ =~ /^(?:[GL][TE]|NE|EQ)$/o
1687 3 82 if (ref $val and ref $val eq 'ARRAY') { }
1690 2 1 if (index($op, 'BETWEEN') >= 0) { }
1 0 elsif ($op =~ /^NOT( IN)?$/) { }
1710 0 82 if (&blessed($val))
1711 0 0 unless $val = _stringify($val)
1716 74 8 if (defined $val) { }
1727 29 53 if ($op eq 'LIKE')
1739 0 0 if carp("Unknown Oro operator $key $op $val")
1758 0 0 $value ? :
0 0 if carp("Unknown Oro pair $key, " . ($value ? $value : '[undef]'))
1767 0 111 unless defined $value
1770 70 41 if ($key =~ /^-(?:limit|offset|distinct)$/) { }
37 4 elsif ($key =~ s/^-(order|group)(?:[-_]by)?$/$1/) { }
4 0 elsif ($key =~ /^-(or|and)$/) { }
0 0 elsif ($key eq '-cache') { }
1771 70 0 if $value =~ /^\d+$/o
1778 2 35 if ($key eq 'group' and ref $value)
1779 1 1 if (ref $value->[-1] and ref $value->[-1] eq 'HASH')
1782 0 1 unless (@$value)
1783 0 0 if carp('"Having" without "Group" is not allowed')
1791 3 34 ref $value ? :
1794 37 1 if ($_ =~ /$VALID_GROUPORDER_REGEX/) { }
1796 17 20 $1 && $1 eq '-' ? :
1805 36 1 if scalar @field_array
1817 4 4 unless (ref $array[0])
1830 2 6 if (@$or_pairs > 1) { }
1849 0 0 if ($chi) { }
1864 62 134 keys %prep ? :
1877 71 11 if (not ref $_) { }
11 0 elsif (ref $_ eq 'ARRAY') { }
1880 70 1 if ($_ =~ /$VALID_FIELD_REGEX/) { }
1894 3 8 if ref $sql
1896 7 4 if $inner_sub
1904 19 40 unless $fields =~ /[\.:=]/o
1912 52 7 if ($_ =~ /$FIELD_REST_RE/) { }
0 7 elsif (/^(?:.+?)\.(?:[^\.]+?)$/) { }
7 33 %treatment ? :
1945 3 59 if ($prep->{'group'})
1949 1 2 if ($prep->{'having'})
1957 1 0 if (@$cond_pairs)
1969 33 29 if (exists $prep->{'order'})
1974 47 15 if ($prep->{'limit'})
1979 21 26 if (defined $prep->{'offset'})
1991 20 3 unless my $ref = &blessed($_[0])
1992 3 0 if (index($_ = "$_[0]", $ref) != 0)
2011 98 44 if ($_[0]{$_[1]} and not ref $_[0]{$_[1]})
2014 19 79 if ($_[2])
2015 19 0 $_[0]{$_[1]} =~ /$NUM_RE/ ? :
2036 1448 5 unless (ref $r)
2043 1 4 if (ref $r eq 'SCALAR') { }
1 3 elsif (ref $r eq 'ARRAY') { }
2052 0 1 unless (ref $r->[0])
2066 3 0 if $s .= '?,'
2082 15 0 if length $last_sql <= 500