Branch Coverage

blib/lib/DBIx/Class/ResultSet.pm
Criterion Covered Total %
branch 556 672 82.7


line true false branch
307 21 33083 if (ref $class)
313 1 33082 if $source->isa('DBIx::Class::ResultSourceHandle')
316 110 32973 unless $attrs
319 26 33057 if ($attrs->{'page'})
336 33056 27 unless $attrs->{'_dark_selector'}
397 85 16470 if (wantarray) { }
16469 1 elsif (defined wantarray) { }
410 1 0 unless (caller)[0] =~ /^DBIx\:\:Class\:\:/
440 3453 14101 unless scalar grep({defined $_;} @_)
443 5601 11953 if (@_ == 1) { }
8493 3460 elsif (@_ == 2 and !defined($_[0]) || ref $_[0] ne '') { }
6 3454 elsif (@_ % 2) { }
1 3453 elsif (@_) { }
455 1 0 unless $rsrc->result_class->isa('DBIx::Class::CDBICompat')
459 1 1 if $i % 2
460 0 1 if not defined $_[$i] or ref $_[$i] ne ''
470 161 5560 if (not &List::Util::first(sub { not $safe{$_}; } , keys %$call_attrs) and !defined($call_cond) || ref $call_cond eq 'HASH' && !keys(%$call_cond) || ref $call_cond eq 'ARRAY' && !@$call_cond)
486 8488 9060 if ($call_attrs and keys %$call_attrs)
494 1655 6833 if (&List::Util::first(sub { exists $call_attrs->{$_}; } , 'columns', 'cols', 'select', 'as'))
502 8 8480 if $old_attrs->{'_dark_selector'}
511 2559 65329 if exists $old_attrs->{$_} or exists $call_attrs->{$_}
515 1 8485 if (my $c = delete $new_attrs->{'cols'})
517 0 1 if ($new_attrs->{'columns'}) { }
529 885 16087 if exists $call_attrs->{$key}
533 6626 1860 unless $old_attrs->{'bind'}
8300 186 unless $call_attrs->{'bind'}
538 21787 13305 if (defined $_)
545 27 17519 if (defined $old_having)
553 155 17389 if $cache
563 1 41543 if (exists $attrs->{'include_columns'})
590 2370 163806 ref $attrs->{$key} eq 'ARRAY' ? :
596 80843 2245 if (not @$as || @$sel) { }
0 2245 elsif (@$as and not @$sel) { }
601 1644 elsif (not @$as) { }
0 1644 elsif (@$as < @$sel) { }
2 1642 elsif ($pref and $attrs->{'_dark_selector'}) { }
608 596 5 unless ($attrs->{'_dark_selector'})
611 5 659 if (ref $_ eq 'HASH' and exists $_->{'-as'}) { }
638 21 elsif (not ref $_ and $_ =~ /^ [^\s\(\)]+ $/x) { }
662 16921 4893 if (defined $left xor defined $right) { }
968 3925 elsif (not defined $left) { }
663 15474 1447 defined $left ? :
709 0 1 if (@bind and ref $bind[-1] eq 'HASH')
784 379 1031 @_ > 1 && ref $_[$#_] eq 'HASH' ? :
789 18 1392 if (exists $attrs->{'key'})
792 18 0 defined $attrs->{'key'} ? :
799 1180 230 if (ref $_[0] eq 'HASH') { }
804 229 1 unless defined $constraint_name
808 0 230 unless @c_cols
812 1 229 unless @c_cols == @_
822 21 22 if (length ref $call_cond->{$key} and my $relinfo = $rsrc->relationship_info($key) and ref(my $val = delete $call_cond->{$key}) ne 'ARRAY')
834 0 20 if $crosstable or ref $rel_cond ne 'HASH'
843 0 1408 exists $attrs->{'alias'} ? :
845 246 1162 if (defined $constraint_name) { }
8 1154 elsif ($self->{'attrs'}{'accessor'} and $self->{'attrs'}{'accessor'} eq 'single') { }
874 945 2196 $b eq 'primary' ? :
908 3141 $a eq 'primary' ? :
880 824 3017 if $seen_column_combinations{join "\000", sort($rsrc->unique_constraint_columns($c_name))}++
894 1 1970 if $_ =~ /\bFilterColumn\b/
900 1 132 @fc_exceptions ? :
1021 133 @unique_queries ? :
907 11 1392 if ($rs->_resolved_attrs->{'collapse'}) { }
909 1 10 if $rs->next
937 0 132 exists $attrs->{'alias'} ? :
946 1556 0 unless $_ =~ /\./
1080 0 2733 if (@_ > 2)
1088 1 2732 if $attrs->{'collapse'}
1090 9 2723 if ($where)
1091 0 9 if (defined $attrs->{'where'}) { }
1094 0 0 ref $_ eq 'ARRAY' ? :
1107 299 2432 unless @$data
1171 0 0 @_ > 1 && ref $_[$#_] eq 'HASH' ? :
1172 0 0 ref $_[0] eq 'HASH' ? :
1200 13 1 $max ? :
1232 65 4823 if (my $cache = $self->get_cache)
1237 2 4821 if ($self->{'attrs'}{'cache'})
1243 1632 3189 unless $self->{'_stashed_results'}
11 4810 if @{[] unless $self->{'_stashed_results'};}
1245 704 4070 unless $self->{'_stashed_results'} = $self->_construct_results
1273 34 1989 if (not $fetch_all || $attrs->{'order_by'} and $attrs->{'collapse'} and my(@pcols) = $rsrc->primary_columns)
1297 1620 7241 if ($fetch_all) { }
109 7132 elsif ($attrs->{'collapse'}) { }
1299 0 1620 $rows ? :
1314 11 8 $attrs->{'order_by'} && $rsrc->schema->storage->_extract_colinfo_of_stable_main_source_order_by_portion($attrs) ? :
19 90 unless defined $attrs->{'_ordered_for_collapse'}
1316 13 96 unless ($attrs->{'_ordered_for_collapse'})
1322 8 5 unless ($cursor->{'_done'})
1323 0 8 $rows ? :
1329 4762 2466 unless $rows
4772 2456 unless ($did_fetch_all or @{[] unless $rows;})
1332 4066 699 if (scalar(my(@r) = $cursor->next))
1337 694 8151 unless $rows
996 7849 unless @{[] unless $rows;}
1340 226 7623 if ($attrs->{'collapse'} and my $aliastypes = $attrs->{'_last_sqlmaker_alias_map'})
1344 341 82 if ($aliastypes->{'multiplying'}{$sel_alias} or $aliastypes->{'premultiplied'}{$sel_alias})
1356 3 2164 if (ref $sel eq 'SCALAR') { }
6 4316 elsif (ref $sel eq 'REF' and ref $$sel eq 'ARRAY') { }
1365 36 2131 if $multiplied_selectors->{$sel} and not $attrs->{'as'}[$i] =~ /\./
1373 1 4657 unless $res_class->can('inflate_result')
1383 4543 109 $inflator_cref == (\&DBIx::Class::Row::inflate_result || die(q[No ::Row::inflate_result() - can't happen])) ? :
4652 3160 unless defined $self->{'_result_inflator'}{'is_core_row'}
1393 96 4561 !$self->{'_result_inflator'}{'is_core_row'} && $inflator_cref == (require DBIx::Class::ResultClass::HashRefInflator && 'DBIx::Class::ResultClass::HashRefInflator'->can('inflate_result')) ? :
4657 3155 unless defined $self->{'_result_inflator'}{'is_hri'}
1396 7546 266 if ($attrs->{'_simple_passthrough_construction'}) { }
1398 51 7495 if ($self->{'_result_inflator'}{'is_hri'}) { }
7491 4 elsif ($self->{'_result_inflator'}{'is_core_row'} and @$rows < 60) { }
1422 0 4 $self->{'_result_inflator'}{'is_core_row'} ? :
1 3 unless eval sprintf($self->{'_result_inflator'}{'is_core_row'} ? '$_ = $inflator_cref->($res_class, $rsrc, { %s }) for @$rows' : '@$rows = map { $inflator_cref->($res_class, $rsrc, { %s } ) } @$rows', join(', ', map({"\$infmap->[$_] => \$_->[$_]";} 0 .. $#$infmap))) . '; 1'
1429 200 9 $self->{'_result_inflator'}{'is_core_row'} ? :
57 209 $self->{'_result_inflator'}{'is_hri'} ? :
1442 223 43 unless $self->{'_row_parser'}{$parser_type}{'cref'}
1453 168 98 if (my $check_non_null_cols = $self->{'_row_parser'}{$parser_type}{'nullcheck'})
1465 0 168 if @violating_idx
1488 2 88 unless my(@r) = $cursor->next
1491 44 12 defined $unrolled_non_null_cols_to_check ? :
210 56 $did_fetch_all || !$attrs->{'collapse'} ? :
1495 56 210 $next_cref ? :
1499 200 66 if ($self->{'_result_inflator'}{'is_core_row'}) { }
9 57 elsif (not $self->{'_result_inflator'}{'is_hri'}) { }
1513 3 7806 if not $fetch_all and @$rows > 1
1558 33101 4043 if ($result_class)
1561 33101 0 unless ref $result_class
1564 1 33096 if ($self->get_cache) { }
1 33095 elsif ($self->{'cursor'} and $self->{'cursor'}{'_pos'}) { }
1597 15 609 if @_ and defined $_[0]
1598 58 551 if $self->get_cache
1607 65 486 if ($self->_has_resolved_attr('collapse', 'group_by')) { }
1615 22 526 if $offset
1616 13 535 if $rows and $rows < $count
1617 1 547 if $count < 0
1645 10 58 if @_
1651 28 30 if ($self->_has_resolved_attr('collapse', 'group_by', 'offset', 'rows')) { }
1693 31 62 if ($attrs->{'collapse'})
1695 0 31 unless $rsrc->_identifying_column_set
1703 90 3 if (my $g = $sub_attrs->{'group_by'}) { }
1711 11 8 if ref $sel eq 'HASH' and $sel->{'-as'}
1718 3 87 if ($attrs->{'having'})
1722 3 0 unless (defined $sql_maker->{'quote_char'} and length $sql_maker->{'quote_char'})
1744 2 1 unless ($seen_having{$part}++)
1756 3 137 if ($colpiece =~ /\./ and not $colpiece =~ /^$attrs->{'alias'}\./)
1766 3 0 @pcols ? :
1813 0 1686 if (@_)
1819 66 1620 if (my $c = $self->get_cache)
1827 12 1587 if $self->{'attrs'}{'cache'}
1906 18 583 if (not $needs_subq and @{$attrs->{'from'};} > 1)
1912 0 18 unless $join_classifications->{'restricting'}
1924 571 30 if (not $needs_subq) { }
1953 20 10 if (@$idcols == 1) { }
0 10 elsif ($storage->_use_multicolumn_in) { }
1968 5 5 if ($existing_group_by or keys %{{} unless $join_classifications->{'multiplying'};})
1973 5 3 unless $join_classifications->{'multiplying'}
1978 2 3 if ($existing_group_by)
1980 8 6 $_ =~ /\./ ? :
1984 1 1 if (join("\000", sort(@current_group_by)) ne join("\000", sort(@{$attrs->{'columns'};})))
2013 495 104 $op eq 'update' ? :
599 1 $cond ? :
2019 9 587 if $guard
2059 0 495 unless ref $values eq 'HASH'
2083 0 1 unless ref $values eq 'HASH'
2117 0 106 if @_
2141 0 270 if @_
2233 0 7744 unless my $data = ref $_[0] eq 'ARRAY' && (@{$_[0];} || (return)) && (ref $_[0][0] eq 'HASH' || ref $_[0][0] eq 'ARRAY') && $_[0]
2243 41 7703 if (defined wantarray)
2246 21 20 if (ref $data->[0] eq 'ARRAY') { }
2248 4 17 if @$data == 1
2250 12 5 if @$data > 2
2260 15 5 if @$data > 1
2266 27 10 if $guard
2267 22 15 wantarray ? :
2287 44603 106 if (ref $data->[$i] eq 'ARRAY') { }
106 0 elsif (ref $data->[$i] eq 'HASH') { }
2290 7659 36944 if ($i == 0) { }
2292 2 7657 if @$data == 1
2303 4 103454 if ($_->{'is_rel'} ||= $$rel_info{$_->{'name'}} && (ref $data->[$i][$_->{'pos'}] eq 'ARRAY' || ref $data->[$i][$_->{'pos'}] eq 'HASH' || defined &blessed($data->[$i][$_->{'pos'}]) && $data->[$i][$_->{'pos'}]->isa('DBIx::Class::Row')) && 1)
2318 4 0 ref $data->[$i][$_->{'pos'}] eq 'ARRAY' ? :
2319 0 5 if (defined &blessed($_) and $_->isa('DBIx::Class::Row'))
2330 4 36940 if ($current_slice_seen_rel_infos)
2344 0 97 if $data_start
2353 12 212 if ($colinfo->{$_}{'is_rel'} ||= $rel_info->{$_} && (ref $data->[$i]{$_} eq 'ARRAY' || ref $data->[$i]{$_} eq 'HASH' || defined &blessed($data->[$i]{$_}) && $data->[$i]{$_}->isa('DBIx::Class::Row')) && 1)
2368 10 2 ref $data->[$i]{$_} eq 'ARRAY' ? :
2369 1 17 if (defined &blessed($_) and $_->isa('DBIx::Class::Row'))
2379 11 94 if ($current_slice_seen_rel_infos)
2391 2 37047 if (grep {$_->{'attrs'}{'is_depends_on'};} @{[] unless $current_slice_seen_rel_infos;})
2393 37034 15 unless $current_slice_seen_rel_infos
2400 5 7693 if ($slices_with_rels)
2412 1 4 unless ($rsrc->_identifying_column_set($ci))
2424 9 7688 if (keys %$rs_data)
2431 4 7693 if $slices_with_rels
2443 0 0 unless $rs_data_vals
2447 0 36940 $rs_data_vals ? :
0 36940 $slices_with_rels ? :
88 15 unless $rs_data_vals
36940 103 ref $data->[$_] eq 'ARRAY' ? :
2452 4 7686 if ($slices_with_rels)
2453 0 4 unless my(@rels) = grep({$colinfo->{$_}{'is_rel'};} keys %$colinfo)
2460 0 9 unless defined $sl->{$rel}
2467 4 5 unless (defined $colinfo->{$rel}{'rs'})
2475 0 4 unless $rsrc->_resolve_relationship_condition('rel_name', $rel, 'self_alias', "\376", 'foreign_alias', "\377")->{'identity_map'}
2488 9 0 ref $sl->{$rel} eq 'ARRAY' ? :
2495 4 7686 if $guard
2519 12 16 if $self->{'pager'}
2522 0 16 if (not defined $attrs->{'page'}) { }
0 16 elsif ($attrs->{'page'} <= 0) { }
2588 0 1500 if @_ > 2
2591 0 1500 unless ref $values eq 'HASH'
2596 6 1494 @$cols_from_relations ? :
2605 0 1498 if (&reftype($new) eq 'HASH' and not keys %$new and &blessed($new))
2634 10381 2079 if (not defined $self->{'cond'}) { }
6 2073 elsif ($self->{'cond'} eq \'1 = 0') { }
2639 0 6 unless $implied_data
2644 0 2117 ($eqs->{$_} || '') eq \'1 = 0' ? :
2680 0 3298 if (grep {$n eq $_;} '-join')
2687 3173 125 unless defined $attr
2689 0 125 if (ref $attr eq 'HASH') { }
64 61 elsif (ref $attr eq 'ARRAY') { }
2690 0 0 if keys %$attr
2693 64 0 if @$attr
2696 41 20 if $attr
2706 0 0 if $extra_checks{'-join'} and ref $attrs->{'from'} eq 'ARRAY' and @{$attrs->{'from'};} > 1
2720 0 14539 unless $query
2724 6713 1661 unless ($key =~ /\./)
2728 1646 15 if $key =~ /^(?:\Q$alias\E\.)?([^.]+)$/
2802 1 3 @_ > 1 && ref $_[$#_] eq 'HASH' ? :
2803 4 0 ref $_[0] eq 'HASH' ? :
2804 2 2 if (keys %$hash and my $row = $self->find($hash, $attrs))
2971 5 25 @_ > 1 && ref $_[$#_] eq 'HASH' ? :
2972 30 0 ref $_[0] eq 'HASH' ? :
2973 7 21 if (keys %$hash and my $row = $self->find($hash, $attrs))
3037 4 11 @_ > 1 && ref $_[$#_] eq 'HASH' ? :
3038 15 0 ref $_[0] eq 'HASH' ? :
3041 9 6 if (defined $row)
3100 2 0 @_ > 1 && ref $_[$#_] eq 'HASH' ? :
3101 2 0 ref $_[0] eq 'HASH' ? :
3104 1 1 if (defined $row)
3155 0 798 if defined $data and ref $data ne 'ARRAY'
3232 14 216 if defined $self->{'related_resultsets'}{$rel}
3238 0 216 unless $rel_info
3281 13 203 if (my $cache = $self->get_cache)
3283 18 21 unless $_->related_resultset($rel)->get_cache
3287 7 6 if @related_cache == @$cache
3426 0 216 unless $self->{'attrs'}
3434 192 24 unless delete $attrs->{'seen_join'}
3439 9 207 if ($attrs->{'from'} and ref $attrs->{'from'} ne 'ARRAY' or $self->_has_resolved_attr(@force_subq_attrs)) { }
22 185 elsif ($attrs->{'from'}) { }
3474 22 194 $seen->{'-relation_chain_depth'} ? :
3496 12 18 if ($rel eq $last_j)
3503 204 12 unless ($already_joined)
3519 11888 9008 if $self->{'_attrs'}
3521 0 9008 unless $self->{'attrs'}
3526 0 36 if $attrs->{'collapse'} and $attrs->{'distinct'}
3530 6573 2435 unless &List::Util::first(sub { exists $attrs->{$_}; } , 'columns', 'cols', 'select', 'as')
3535 10233 16791 if $attrs->{$_} or $$attrs{"+$_"}
3540 7888 1120 if (my $cols = delete $attrs->{'columns'})
3541 7888 0 ref $cols eq 'ARRAY' ? :
3542 1068 34870 if (ref $c eq 'HASH') { }
3559 1170 0 ref $attrs->{'as'} eq 'ARRAY' ? :
3560 1170 7838 if $attrs->{'as'}
3561 1175 0 ref $attrs->{'select'} eq 'ARRAY' ? :
3562 1175 7833 if $attrs->{'select'}
3565 2098 35219 ref $_ || $_ =~ /\./ ? :
3568 222 37060 $_ =~ /^\Q$alias.\E(.+)$/ ? :
3576 10 35995 if ($$seen{"$sel[$i] \000\000 $as[$i]"}++) { }
0 35995 elsif ($$seen{$as[$i]}++) { }
3600 720 8288 if ($attrs->{'join'} or $attrs->{'prefetch'})
3603 0 720 if ref $attrs->{'from'} ne 'ARRAY'
3607 485 235 if (defined $attrs->{'prefetch'})
3617 672 48 unless $attrs->{'seen_join'}
3620 46 674 $attrs->{'seen_join'} && keys %{$$attrs{'seen_join'};} ? :
3628 3583 14433 if (defined $attrs->{$attr})
3632 629 2954 ref $attrs->{$attr} eq 'ARRAY' ? :
3635 23 3560 unless @{$attrs->{$attr};}
3642 485 8523 if defined $attrs->{'prefetch'}
3644 353 8655 if ($prefetch)
3647 1 352 if $attrs->{'_dark_selector'}
3650 0 352 if defined $attrs->{'collapse'} and not $attrs->{'collapse'}
3658 352 0 if (ref $attrs->{'from'} eq 'ARRAY')
3663 0 529 unless $j->[0]{'-alias'}
3664 0 529 unless $j->[0]{'-join_path'}
3665 12 517 if ($j->[0]{'-relation_chain_depth'} || 0) < $start_depth
3690 388 8619 if ($attrs->{'collapse'})
3692 388 0 if (ref $attrs->{'from'} eq 'ARRAY') { }
3694 63 325 if (@{$attrs->{'from'};} == 1) { }
3706 48 325 if (ref $t eq 'ARRAY')
3710 325 48 if $t->{'-alias'} and $t->{'-alias'} eq $alias
3715 95 223 unless ($attrs->{'_main_source_premultiplied'} or &List::Util::first(sub { not $_->[0]{'-is_single'}; } , @fromlist))
3732 70 8937 if (delete $attrs->{'distinct'})
3733 1 69 if ($attrs->{'group_by'}) { }
3746 61 8 unless $attrs->{'collapse'}
3763 15 8992 if (my $page = delete $attrs->{'page'})
3777 734 1304 if (ref $attr eq 'HASH') { }
940 364 elsif (ref $attr eq 'ARRAY') { }
3791 474 888 if (ref $element eq 'HASH') { }
340 548 elsif (ref $element eq 'ARRAY') { }
3816 44 280 if (defined $a xor defined $b) { }
10 270 elsif (not defined $a) { }
3823 92 178 if (ref $b eq 'HASH') { }
3825 1 91 unless defined $b_key
3826 35 57 if (ref $a eq 'HASH') { }
3828 1 34 unless defined $a_key
3829 25 10 if ($a_key eq $b_key) { }
3835 20 37 $a eq $b_key ? :
3838 30 148 if (ref $a eq 'HASH') { }
3840 12 18 $b eq $a_key ? :
3842 48 100 $b eq $a ? :
3850 1790 1042 unless defined $orig
3851 23 1019 unless defined $import
3862 90 209 if ($score > $best_candidate->{'score'})
3868 176 689 ref $import_element eq 'HASH' ? :
3869 96 769 unless defined $import_key
3871 794 71 if ($best_candidate->{'score'} == 0 or exists $seen_keys->{$import_key}) { }
3876 46 25 if (ref $orig_best ne 'HASH') { }
15 10 elsif (ref $import_element eq 'HASH') { }
3886 841 178 @$orig ? :
3901 74 0 if ($defl xor $defr) { }
0 0 elsif (not $defl) { }
3902 0 74 $defl ? :
3915 5933 0 unless defined $_[0]
3920 1 869 unless defined $_[0] or keys %{$_[1];}
3921 869 0 unless defined $_[0]
3922 0 0 unless keys %{$_[1];}
3928 10276 1 unless defined $_[1]
3933 5 120 unless my(@ret) = @{$_[0];}
3940 0 0 unless @{$_[0];}
3941 0 0 unless keys %{$_[1];}
3948 0 0 unless keys %{$_[0];} or defined $_[1]
3949 0 0 unless defined $_[1]
3950 0 0 unless keys %{$_[0];}
3954 0 0 unless keys %{$_[0];} or @{$_[1];}
3955 0 0 unless @{$_[1];}
3956 0 0 unless keys %{$_[0];}
3961 0 0 unless keys %{$_[0];} or keys %{$_[1];}
3962 0 0 unless keys %{$_[1];}
3963 0 0 unless keys %{$_[0];}
3964 0 0 if $_[0] eq $_[1]
3985 1 145 if ($to_serialize->{'pager'} and ref $to_serialize->{'pager'}{'total_entries'} eq 'CODE')
4011 56 1 if (ref $self and my $rsrc = $self->result_source) { }