| 1 | package # hide from the pauses | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | DBIx::Class::ResultSource::RowParser; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 436 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 436 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 436 | ▶ | use base 'DBIx::Class'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 419 | ▶ | use Try::Tiny; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 419 | ▶ | use DBIx::Class::ResultSource::RowParser::Util qw( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | assemble_simple_parser | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | assemble_collapsing_parser | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 419 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 419 | ▶ | use namespace::clean; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | # Accepts one or more relationships for the current source and returns an | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | # array of column names for each of those relationships. Column names are | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | # prefixed relative to the current source, in accordance with where they appear | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | # in the supplied relationships. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 966 | ▶ | sub _resolve_prefetch { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_resolve_prefetch: called CC=12 SCAR=25.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 966 | my ($self, $pre, $alias, $alias_map, $order, $pref_path) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 966 | ▶ | $pref_path ||= []; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$pref_path ||= []
MC/DC100%1/1
$pref_path ||= []
$pref_path
Truth table100%2/2
A
A= $pref_path
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 966 | ▶ | if (not defined $pre or not length $pre) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
Condition100%3/3
defined $pre && length $pre
MC/DC100%2/2
defined $pre && length $pre
defined $pre
length $pre
Truth table100%3/3
A && B
A= defined $preB= length $pre
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 99 | return (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | elsif( ref $pre eq 'ARRAY' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | return | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 362 | map { $self->_resolve_prefetch( $_, $alias, $alias_map, $order, [ @$pref_path ] ) } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | @$pre; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | elsif( ref $pre eq 'HASH' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | my @ret = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | map { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 99 | $self->_resolve_prefetch($_, $alias, $alias_map, $order, [ @$pref_path ] ), | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | $self->related_source($_)->_resolve_prefetch( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 98 | $pre->{$_}, "${alias}.$_", $alias_map, $order, [ @$pref_path, $_] ) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | } keys %$pre; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 99 | return @ret; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | elsif( ref $pre ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 1 | $self->throw_exception( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | "don't know how to resolve prefetch reftype ".ref($pre)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 411 | my $p = $alias_map; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 411 | $p = $p->{$_} for (@$pref_path, $pre); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | $self->throw_exception ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | "Unable to resolve prefetch '$pre' - join alias map does not contain an entry for path: " | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | . join (' -> ', @$pref_path, $pre) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 411 | ▶ | ) if (ref $p->{-join_aliases} ne 'ARRAY' or not @{$p->{-join_aliases}} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
ref $p->{"-join_aliases"} ne "ARRAY" or not @{$p->{"-join_aliases"};}
MC/DC0%0/2
ref $p->{"-join_aliases"} ne "ARRAY" or not @{$p->{"-join_aliases"};}
ref $p->{"-join_aliases"} ne "ARRAY"
not @{$p->{"-join_aliases"};}
Truth table33%1/3
A or not(B)
A= ref $p->{"-join_aliases"} ne "ARRAY"B= not @{$p->{"-join_aliases"};}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 411 | my $as = shift @{$p->{-join_aliases}}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 411 | my $rel_info = $self->relationship_info( $pre ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 411 | ▶ | $self->throw_exception( $self->source_name . " has no such relationship '$pre'" ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | unless $rel_info; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 411 | ▶ | my $as_prefix = ($alias =~ /^.*?\.(.+)$/ ? $1.'.' : ''); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 411 | return map { [ "${as}.$_", "${as_prefix}${pre}.$_", ] } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | $self->related_source($pre)->columns; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | # Takes an arrayref of {as} dbic column aliases and the collapse and select | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | # attributes from the same $rs (the selector requirement is a temporary | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | # workaround... I hope), and returns a coderef capable of: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | # my $me_pref_clps = $coderef->([$rs->cursor->next/all]) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | # Where the $me_pref_clps arrayref is the future argument to inflate_result() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | # For an example of this coderef in action (and to see its guts) look at | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | # t/resultset/rowparser_internals.t | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | # This is a huge performance win, as we call the same code for every row | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | # returned from the db, thus avoiding repeated method lookups when traversing | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | # relationships | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | # Also since the coderef is completely stateless (the returned structure is | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | # always fresh on every new invocation) this is a very good opportunity for | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | # memoization if further speed improvements are needed | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | # The way we construct this coderef is somewhat fugly, although the result is | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | # really worth it. The final coderef does not perform any kind of recursion - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | # the entire nested structure constructor is rolled out into a single scope. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | # In any case - the output of this thing is meticulously micro-tested, so | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | # any sort of adjustment/rewrite should be relatively easy (fsvo relatively) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 235 | ▶ | sub _mk_row_parser { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_mk_row_parser: called CC=8 SCAR=20.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | # $args and $attrs are separated to delineate what is core collapser stuff and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | # what is dbic $rs specific | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 234 | my ($self, $args, $attrs) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | die "HRI without pruning makes zero sense" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 234 | ▶ | if ( $args->{hri_style} && ! $args->{prune_null_branches} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$args->{"hri_style"} and not $args->{"prune_null_branches"}
MC/DC0%0/2
$args->{"hri_style"} and not $args->{"prune_null_branches"}
$args->{"hri_style"}
not $args->{"prune_null_branches"}
Truth table66%2/3
A and not(B)
A= $args->{"hri_style"}B= not $args->{"prune_null_branches"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | my %common = ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | hri_style => $args->{hri_style}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | prune_null_branches => $args->{prune_null_branches}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | val_index => { map | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 2215 | { $args->{inflate_map}[$_] => $_ } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 234 | ( 0 .. $#{$args->{inflate_map}} ) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 234 | my $check_null_columns; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 234 | ▶ | my $src = (! $args->{collapse} ) ? assemble_simple_parser(\%common) : do { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | my $collapse_map = $self->_resolve_collapse ({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | # FIXME | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | # only consider real columns (not functions) during collapse resolution | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | # this check shouldn't really be here, as fucktards are not supposed to | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | # alias random crap to existing column names anyway, but still - just in | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | # case | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | # FIXME !!!! - this does not yet deal with unbalanced selectors correctly | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | # (it is now trivial as the attrs specify where things go out of sync | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | # needs MOAR tests) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | as => { map | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 1653 | ▶ | { ref $attrs->{select}[$common{val_index}{$_}] ? () : ( $_ => $common{val_index}{$_} ) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 166 | keys %{$common{val_index}} | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | premultiplied => $args->{premultiplied}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 166 | }); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | $check_null_columns = $collapse_map->{-identifying_columns} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 166 | ▶ | if @{$collapse_map->{-identifying_columns}}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 166 | assemble_collapsing_parser({ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | %common, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | collapse_map => $collapse_map, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 234 | utf8::upgrade($src) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | if DBIx::Class::_ENV_::STRESSTEST_UTF8_UPGRADE_GENERATED_COLLAPSER_SOURCE; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | return ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 234 | ▶ | $args->{eval} ? ( eval "sub $src" || die $@ ) : $src, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Branch: 1 branch
Condition50%1/2
eval "sub $src" or die $@
MC/DC0%0/1
eval "sub $src" or die $@
eval "sub $src"
Truth table50%1/2
A
A= eval "sub $src"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | $check_null_columns, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | # Takes an arrayref selection list and generates a collapse-map representing | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | # row-object fold-points. Every relationship is assigned a set of unique, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | # non-nullable columns (which may *not even be* from the same resultset) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | # and the collapser will use this information to correctly distinguish | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | # data of individual to-be-row-objects. See t/resultset/rowparser_internals.t | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | # for extensive RV examples | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 562 | ▶ | sub _resolve_collapse { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_resolve_collapse: called CC=67 SCAR=42.7
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 561 | my ($self, $args, $common_args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | # for comprehensible error messages put ourselves at the head of the relationship chain | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 561 | ▶ | $args->{_rel_chain} ||= [ $self->source_name ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$args->{"_rel_chain"} ||= [$self->source_name]
MC/DC100%1/1
$args->{"_rel_chain"} ||= [$self->source_name]
$args->{"_rel_chain"}
Truth table100%2/2
A
A= $args->{"_rel_chain"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | # record top-level fully-qualified column index, signify toplevelness | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 561 | ▶ | unless ($common_args->{_as_fq_idx}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 169 | $common_args->{_as_fq_idx} = { %{$args->{as}} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 169 | $args->{_is_top_level} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 561 | my ($my_cols, $rel_cols); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 561 | for (keys %{$args->{as}}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 3675 | ▶ | if ($_ =~ /^ ([^\.]+) \. (.+) /x) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 1953 | $rel_cols->{$1}{$2} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 1723 | $my_cols->{$_} = {}; # important for ||='s below | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 561 | my $relinfo; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | # run through relationships, collect metadata | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 561 | for my $rel (keys %$rel_cols) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 379 | my $inf = $self->relationship_info ($rel); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | $relinfo->{$rel} = { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | is_single => ( $inf->{attrs}{accessor} && $inf->{attrs}{accessor} ne 'multi' ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 379 | ▶ | is_inner => ( ( $inf->{attrs}{join_type} || '' ) !~ /^left/i), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition80%4/5
$inf->{'attrs'}{'accessor'} && $inf->{'attrs'}{'accessor'} ne 'multi'
$inf->{'attrs'}{'join_type'} || ''
MC/DC50%1/2
$inf->{'attrs'}{'accessor'} && $inf->{'attrs'}{'accessor'} ne 'multi'
$inf->{'attrs'}{'accessor'}
$inf->{'attrs'}{'accessor'} ne 'multi'
MC/DC100%1/1
$inf->{'attrs'}{'join_type'} || ''
$inf->{'attrs'}{'join_type'}
Truth table66%2/3
A && B
A= $inf->{'attrs'}{'accessor'}B= $inf->{'attrs'}{'accessor'} ne 'multi'
Truth table100%2/2
A
A= $inf->{'attrs'}{'join_type'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | rsrc => $self->related_source($rel), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | # FIME - need to use _resolve_cond here instead | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 379 | my $cond = $inf->{cond}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 379 | ▶ | if ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%6/9
ref $cond eq "HASH" and keys %$cond and not grep({not $_ =~ /^foreign\./;} keys %$cond) and not grep({not $_ =~ /^self\./;} values %$cond)
ref $cond eq "HASH" and keys %$cond and not grep({not $_ =~ /^foreign\./;} keys %$cond)
ref $cond eq "HASH" and keys %$cond
MC/DC25%1/4
ref $cond eq "HASH" and keys %$cond and not grep({not $_ =~ /^foreign\./;} keys %$cond) and not grep({not $_ =~ /^self\./;} values %$cond)
ref $cond eq "HASH"
keys %$cond
not grep({not $_ =~ /^foreign\./;} keys %$cond)
not grep({not $_ =~ /^self\./;} values %$cond)
Truth table40%2/5
A and B and not(C) and not(D)
A= ref $cond eq "HASH"B= keys %$condC= not grep({not $_ =~ /^foreign\./;} keys %$cond)D= not grep({not $_ =~ /^self\./;} values %$cond)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | ref $cond eq 'HASH' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | keys %$cond | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 378 | ! grep { $_ !~ /^foreign\./ } (keys %$cond) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 378 | ! grep { $_ !~ /^self\./ } (values %$cond) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 378 | for my $f (keys %$cond) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 378 | my $s = $cond->{$f}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 378 | $_ =~ s/^ (?: foreign | self ) \.//x for ($f, $s); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 378 | $relinfo->{$rel}{fk_map}{$s} = $f; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | # inject non-left fk-bridges from *INNER-JOINED* children (if any) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 561 | for my $rel (grep { $relinfo->{$_}{is_inner} } keys %$relinfo) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 124 | my $ri = $relinfo->{$rel}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 124 | for (keys %{$ri->{fk_map}} ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | # need to know source from *our* pov, hence $rel.col | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | $my_cols->{$_} ||= { via_fk => "$rel.$ri->{fk_map}{$_}" } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 124 | ▶ | if defined $rel_cols->{$rel}{$ri->{fk_map}{$_}} # in fact selected | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%2/2
$my_cols->{$_} ||= {"via_fk", qq[$rel.$ri->{"fk_map"}{$_}]}
MC/DC100%1/1
$my_cols->{$_} ||= {"via_fk", qq[$rel.$ri->{"fk_map"}{$_}]}
$my_cols->{$_}
Truth table100%2/2
A
A= $my_cols->{$_}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | # if the parent is already defined *AND* we have an inner reverse relationship | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | # (i.e. do not exist without it) , assume all of its related FKs are selected | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | # (even if they in fact are NOT in the select list). Keep a record of what we | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | # assumed, and if any such phantom-column becomes part of our own collapser, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | # throw everything assumed-from-parent away and replace with the collapser of | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | # the parent (whatever it may be) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 561 | my $assumed_from_parent; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 561 | ▶ | if ( ! $args->{_parent_info}{underdefined} and ! $args->{_parent_info}{rev_rel_is_optional} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$args->{"_parent_info"}{"underdefined"} or $args->{"_parent_info"}{"rev_rel_is_optional"}
MC/DC100%2/2
$args->{"_parent_info"}{"underdefined"} or $args->{"_parent_info"}{"rev_rel_is_optional"}
$args->{"_parent_info"}{"underdefined"}
$args->{"_parent_info"}{"rev_rel_is_optional"}
Truth table100%3/3
A or B
A= $args->{"_parent_info"}{"underdefined"}B= $args->{"_parent_info"}{"rev_rel_is_optional"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 395 | ▶ | for my $col ( values %{$args->{_parent_info}{rel_condition} || {}} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$args->{'_parent_info'}{'rel_condition'} || {}
MC/DC100%1/1
$args->{'_parent_info'}{'rel_condition'} || {}
$args->{'_parent_info'}{'rel_condition'}
Truth table100%2/2
A
A= $args->{'_parent_info'}{'rel_condition'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | 227 | ▶ | next if exists $my_cols->{$col}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | 54 | $my_cols->{$col} = { via_collapse => $args->{_parent_info}{collapse_on_idcols} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 54 | $assumed_from_parent->{columns}{$col}++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | # get colinfo for everything | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 561 | ▶ | if ($my_cols) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 541 | my $ci = $self->columns_info; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | 541 | $my_cols->{$_}{colinfo} = $ci->{$_} for keys %$my_cols; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | 561 | my $collapse_map; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | # first try to reuse the parent's collapser (i.e. reuse collapser over 1:1) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | # (makes for a leaner coderef later) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | 561 | ▶ | unless ($collapse_map->{-identifying_columns}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | $collapse_map->{-identifying_columns} = $args->{_parent_info}{collapse_on_idcols} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 561 | ▶ | if $args->{_parent_info}{collapser_reusable}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | # Still don't know how to collapse - try to resolve based on our columns (plus already inserted FK bridges) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | 561 | ▶ | if ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
not $collapse_map->{"-identifying_columns"} and $my_cols and my $idset = $self->_identifying_column_set({map({$_, $my_cols->{$_}{"colinfo"};} keys %$my_cols)})
not $collapse_map->{"-identifying_columns"} and $my_cols
MC/DC100%3/3
not $collapse_map->{"-identifying_columns"} and $my_cols and my $idset = $self->_identifying_column_set({map({$_, $my_cols->{$_}{"colinfo"};} keys %$my_cols)})
not $collapse_map->{"-identifying_columns"}
$my_cols
my $idset = $self->_identifying_column_set({map({$_, $my_cols->{$_}{"colinfo"};} keys %$my_cols)})
Truth table100%4/4
not(A) and B and C
A= not $collapse_map->{"-identifying_columns"}B= $my_colsC= my $idset = $self->_identifying_column_set({map({$_, $my_cols->{$_}{"colinfo"};} keys %$my_cols)})
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | ! $collapse_map->{-identifying_columns} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | $my_cols | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | 1541 | my $idset = $self->_identifying_column_set ({map { $_ => $my_cols->{$_}{colinfo} } keys %$my_cols}) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | # see if the resulting collapser relies on any implied columns, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | # and fix stuff up if this is the case | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 423 | my @reduced_set = grep { ! $assumed_from_parent->{columns}{$_} } @$idset; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | $collapse_map->{-identifying_columns} = [ __unique_numlist( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | 423 | ▶ | @{ $args->{_parent_info}{collapse_on_idcols}||[] }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$args->{'_parent_info'}{'collapse_on_idcols'} || []
MC/DC100%1/1
$args->{'_parent_info'}{'collapse_on_idcols'} || []
$args->{'_parent_info'}{'collapse_on_idcols'}
Truth table100%2/2
A
A= $args->{'_parent_info'}{'collapse_on_idcols'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | (map | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | 423 | my $fqc = join ('.', | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | 496 | ▶ | @{$args->{_rel_chain}}[1 .. $#{$args->{_rel_chain}}], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$my_cols->{$_}{'via_fk'} || $_
MC/DC0%0/2
$my_cols->{$_}{'via_fk'} || $_
$my_cols->{$_}{'via_fk'}
$_
Truth table66%2/3
A || B
A= $my_cols->{$_}{'via_fk'}B= $_
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 496 | ( $my_cols->{$_}{via_fk} || $_ ), | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 496 | $common_args->{_as_fq_idx}->{$fqc}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | @reduced_set | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | )]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | # Stil don't know how to collapse - keep descending down 1:1 chains - if | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | # a related non-LEFT 1:1 is resolvable - its condition will collapse us | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | # too | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | 561 | ▶ | unless ($collapse_map->{-identifying_columns}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | 42 | my @candidates; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | 42 | for my $rel (keys %$relinfo) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 53 | ▶ | next unless ($relinfo->{$rel}{is_single} && $relinfo->{$rel}{is_inner}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$relinfo->{$rel}{"is_single"} and $relinfo->{$rel}{"is_inner"}
MC/DC100%2/2
$relinfo->{$rel}{"is_single"} and $relinfo->{$rel}{"is_inner"}
$relinfo->{$rel}{"is_single"}
$relinfo->{$rel}{"is_inner"}
Truth table100%3/3
A and B
A= $relinfo->{$rel}{"is_single"}B= $relinfo->{$rel}{"is_inner"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | 28 | ▶ | if ( my $rel_collapse = $relinfo->{$rel}{rsrc}->_resolve_collapse ({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | as => $rel_cols->{$rel}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | 28 | _rel_chain => [ @{$args->{_rel_chain}}, $rel ], | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | _parent_info => { underdefined => 1 }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | }, $common_args)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | 28 | push @candidates, $rel_collapse->{-identifying_columns}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | # get the set with least amount of columns | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | # FIXME - maybe need to implement a data type order as well (i.e. prefer several ints | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | # to a single varchar) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | 42 | ▶ | if (@candidates) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | 28 | ($collapse_map->{-identifying_columns}) = sort { scalar @$a <=> scalar @$b } (@candidates); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | # Stil don't know how to collapse, and we are the root node. Last ditch | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | # effort in case we are *NOT* premultiplied. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | # Run through *each multi* all the way down, left or not, and all | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | # *left* singles (a single may become a multi underneath) . When everything | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | # gets back see if all the rels link to us definitively. If this is the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | # case we are good - either one of them will define us, or if all are NULLs | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | # we know we are "unique" due to the "non-premultiplied" check | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | 561 | ▶ | if ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%4/6
not $collapse_map->{"-identifying_columns"} || $args->{"premultiplied"} and $args->{"_is_top_level"}
$collapse_map->{'-identifying_columns'} || $args->{'premultiplied'}
MC/DC33%1/3
not $collapse_map->{"-identifying_columns"} || $args->{"premultiplied"} and $args->{"_is_top_level"}
$collapse_map->{'-identifying_columns'}
$args->{'premultiplied'}
$args->{"_is_top_level"}
Truth table50%2/4
not(A || B) and C
A= $collapse_map->{'-identifying_columns'}B= $args->{'premultiplied'}C= $args->{"_is_top_level"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | ! $collapse_map->{-identifying_columns} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | ! $args->{premultiplied} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | $args->{_is_top_level} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | 15 | my (@collapse_sets, $uncollapsible_chain); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | 15 | for my $rel (keys %$relinfo) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | # we already looked at these higher up | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | 23 | ▶ | next if ($relinfo->{$rel}{is_single} && $relinfo->{$rel}{is_inner}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$relinfo->{$rel}{"is_single"} and $relinfo->{$rel}{"is_inner"}
MC/DC0%0/2
$relinfo->{$rel}{"is_single"} and $relinfo->{$rel}{"is_inner"}
$relinfo->{$rel}{"is_single"}
$relinfo->{$rel}{"is_inner"}
Truth table66%2/3
A and B
A= $relinfo->{$rel}{"is_single"}B= $relinfo->{$rel}{"is_inner"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | 23 | ▶ | if (my $clps = $relinfo->{$rel}{rsrc}->_resolve_collapse ({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | as => $rel_cols->{$rel}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | 23 | _rel_chain => [ @{$args->{_rel_chain}}, $rel ], | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | _parent_info => { underdefined => 1 }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | }, $common_args) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | # for singles use the idcols wholesale (either there or not) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | 23 | ▶ | if ($relinfo->{$rel}{is_single}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | 9 | push @collapse_sets, $clps->{-identifying_columns}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | elsif (! $relinfo->{$rel}{fk_map}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | 1 | $uncollapsible_chain = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | 1 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | 15 | my $defined_cols_parent_side; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | 15 | for my $fq_col ( grep { /^$rel\.[^\.]+$/ } keys %{$args->{as}} ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | 39 | my ($col) = $fq_col =~ /([^\.]+)$/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | 39 | $defined_cols_parent_side->{$_} = $args->{as}{$fq_col} for grep | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | 39 | { $relinfo->{$rel}{fk_map}{$_} eq $col } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | 39 | keys %{$relinfo->{$rel}{fk_map}} | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | ; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | 15 | ▶ | if (my $set = $self->_identifying_column_set([ keys %$defined_cols_parent_side ]) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | 15 | push @collapse_sets, [ sort map { $defined_cols_parent_side->{$_} } @$set ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | 1 | $uncollapsible_chain = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | 1 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | 1 | $uncollapsible_chain = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | 1 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | 15 | ▶ | unless ($uncollapsible_chain) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | # if we got here - we are good to go, but the construction is tricky | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | # since our children will want to include our collapse criteria - we | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | # don't give them anything (safe, since they are all collapsible on their own) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | # in addition we record the individual collapse possibilities | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | # of all left children node collapsers, and merge them in the rowparser | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | # coderef later | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | 15 | $collapse_map->{-identifying_columns} = []; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | $collapse_map->{-identifying_columns_variants} = [ sort { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | 15 | (scalar @$a) <=> (scalar @$b) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | or | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | # Poor man's max() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | 1 | ( sort { $b <=> $a } @$a )[0] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | <=> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | 9 | ▶ | ( sort { $b <=> $a } @$b )[0] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
scalar @$a <=> scalar @$b || (sort {$b <=> $a;} @$a)[0] <=> (sort {$b <=> $a;} @$b)[0]
MC/DC0%0/2
scalar @$a <=> scalar @$b || (sort {$b <=> $a;} @$a)[0] <=> (sort {$b <=> $a;} @$b)[0]
scalar @$a <=> scalar @$b
(sort {$b <=> $a;} @$a)[0] <=> (sort {$b <=> $a;} @$b)[0]
Truth table33%1/3
A || B
A= scalar @$a <=> scalar @$bB= (sort {$b <=> $a;} @$a)[0] <=> (sort {$b <=> $a;} @$b)[0]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | } @collapse_sets ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | # stop descending into children if we were called by a parent for first-pass | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | # and don't despair if nothing was found (there may be other parallel branches | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | # to dive into) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | 561 | ▶ | if ($args->{_parent_info}{underdefined}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | 50 | ▶ | return $collapse_map->{-identifying_columns} ? $collapse_map : undef | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | # nothing down the chain resolved - can't calculate a collapse-map | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | elsif (! $collapse_map->{-identifying_columns}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | $self->throw_exception ( sprintf | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | "Unable to calculate a definitive collapse column set for %s%s: fetch more unique non-nullable columns", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | $self->source_name, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | 1 | @{$args->{_rel_chain}} > 1 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | 1 | ▶ | ? sprintf (' (last member of the %s chain)', join ' -> ', @{$args->{_rel_chain}} ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | : '' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | , | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | # If we got that far - we are collapsable - GREAT! Now go down all children | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | # a second time, and fill in the rest | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | $collapse_map->{-identifying_columns} = [ __unique_numlist( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | 512 | ▶ | @{ $args->{_parent_info}{collapse_on_idcols}||[] }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$args->{'_parent_info'}{'collapse_on_idcols'} || []
MC/DC100%1/1
$args->{'_parent_info'}{'collapse_on_idcols'} || []
$args->{'_parent_info'}{'collapse_on_idcols'}
Truth table100%2/2
A
A= $args->{'_parent_info'}{'collapse_on_idcols'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | 512 | @{ $collapse_map->{-identifying_columns} }, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | )]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | 512 | my @id_sets; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | 512 | for my $rel (sort keys %$relinfo) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | $collapse_map->{$rel} = $relinfo->{$rel}{rsrc}->_resolve_collapse ({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | 1820 | as => { map { $_ => 1 } ( keys %{$rel_cols->{$rel}} ) }, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | 344 | _rel_chain => [ @{$args->{_rel_chain}}, $rel], | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | _parent_info => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | # shallow copy | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | 344 | ▶ | collapse_on_idcols => [ @{$collapse_map->{-identifying_columns}} ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | rel_condition => $relinfo->{$rel}{fk_map}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | is_optional => ! $relinfo->{$rel}{is_inner}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | # if there is at least one *inner* reverse relationship which is HASH-based (equality only) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | # we can safely assume that the child can not exist without us | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | rev_rel_is_optional => ( grep | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | 585 | ▶ | { ref $_->{cond} eq 'HASH' and ($_->{attrs}{join_type}||'') !~ /^left/i } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition80%4/5
ref $_->{'cond'} eq 'HASH' && !(($_->{'attrs'}{'join_type'} || '') =~ /^left/i)
$_->{'attrs'}{'join_type'} || ''
MC/DC50%1/2
ref $_->{'cond'} eq 'HASH' && !(($_->{'attrs'}{'join_type'} || '') =~ /^left/i)
ref $_->{'cond'} eq 'HASH'
$_->{'attrs'}{'join_type'}
Truth table66%2/3
A && not(B)
A= ref $_->{'cond'} eq 'HASH'B= $_->{'attrs'}{'join_type'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | 344 | ▶ | values %{ $self->reverse_relationship_info($rel) }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
$relinfo->{$rel}{"is_single"} and $relinfo->{$rel}{"is_inner"} and @{$collapse_map->{"-identifying_columns"};}
$relinfo->{$rel}{"is_single"} and $relinfo->{$rel}{"is_inner"}
MC/DC66%2/3
$relinfo->{$rel}{"is_single"} and $relinfo->{$rel}{"is_inner"} and @{$collapse_map->{"-identifying_columns"};}
$relinfo->{$rel}{"is_single"}
$relinfo->{$rel}{"is_inner"}
@{$collapse_map->{"-identifying_columns"};}
Truth table75%3/4
A and B and C
A= $relinfo->{$rel}{"is_single"}B= $relinfo->{$rel}{"is_inner"}C= @{$collapse_map->{"-identifying_columns"};}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | ) ? 0 : 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | # if this is a 1:1 our own collapser can be used as a collapse-map | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | # (regardless of left or not) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | collapser_reusable => ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | $relinfo->{$rel}{is_single} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | && | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | $relinfo->{$rel}{is_inner} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | && | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | 344 | @{$collapse_map->{-identifying_columns}} | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | ) ? 1 : 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | }, $common_args ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | 344 | ▶ | $collapse_map->{$rel}{-is_single} = 1 if $relinfo->{$rel}{is_single}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | 344 | ▶ | $collapse_map->{$rel}{-is_optional} ||= 1 unless $relinfo->{$rel}{is_inner}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
$collapse_map->{$rel}{"-is_optional"} ||= 1
MC/DC0%0/1
$collapse_map->{$rel}{"-is_optional"} ||= 1
$collapse_map->{$rel}{"-is_optional"}
Truth table50%1/2
A
A= $collapse_map->{$rel}{"-is_optional"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | 512 | return $collapse_map; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | # adding a dep on MoreUtils *just* for this is retarded | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | 934 | ▶ | sub __unique_numlist { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__unique_numlist: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | 934 | sort { $a <=> $b } keys %{ {map { $_ => 1 } @_ }} | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | 380 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||