use strict;
use warnings;
-use List::Util 'first';
-use DBIx::Class::_Util 'perlstring';
+use DBIx::Class::_Util qw( perlstring dump_value );
use constant HAS_DOR => ( "$]" < 5.010 ? 0 : 1 );
my @path_parts = map { sprintf
"( ( defined \$cur_row_data->[%d] ) && (join qq(\xFF), '', %s, '') )",
$_->[0], # checking just first is enough - one ID defined, all defined
- ( join ', ', map { ++$variant_idcols->{$_} and " \$cur_row_ids{$_} " } @$_ ),
+ ( join ', ', map { $variant_idcols->{$_} = 1; " \$cur_row_ids{$_} " } @$_ ),
} @variants;
my $virtual_column_idx = (scalar keys %{$args->{val_index}} ) + 1;
};
}
else {
- die('Unexpected collapse map contents');
+ DBIx::Class::Exception->throw(
+ 'Unexpected collapse map contents: ' . dump_value $args->{collapse_map},
+ 1,
+ )
}
my ($data_assemblers, $stats) = __visit_infmap_collapse ($args);
)
;
- my $parser_src = sprintf (<<'EOS', $row_id_defs, $top_node_key_assembler||'', $top_node_key, join( "\n", @{$data_assemblers||[]} ) );
+ my $parser_src = sprintf (<<'EOS', $row_id_defs, $top_node_key_assembler||'', $top_node_key, join( "\n", @$data_assemblers ) );
### BEGIN LITERAL STRING EVAL
my $rows_pos = 0;
my ($result_pos, @collapse_idx, $cur_row_data, %%cur_row_ids );
if (
$relinfo->{-is_optional}
- and
- defined ( my $first_distinct_child_idcol = first
+ ) {
+
+ my ($first_distinct_child_idcol) = grep
{ ! $known_present_ids->{$_} }
@{$relinfo->{-identifying_columns}}
- )
- ) {
+ ;
+
+ DBIx::Class::Exception->throw(
+ "An optional node *without* a distinct identifying set shouldn't be possible: " . dump_value $args->{collapse_map},
+ 1,
+ ) unless defined $first_distinct_child_idcol;
if ($args->{prune_null_branches}) {
title => 'Oxygene',
year => 1976,
artist => { name => 'JMJ' },
+ artwork => {},
tracks => [
{ title => 'o2', position => 2}, # the position should not be needed here, bug in MC
],
],
"Expected output of collapsing 1:M with empty root selection $native_inflator",
);
+
+ cmp_structures (
+ rs_contents( $schema->resultset ('CD')->search_rs (
+ {
+ 'tracks.title' => 'e2',
+ 'cds.title' => 'Oxygene',
+ },
+ {
+ collapse => 1,
+ join => [
+ 'tracks',
+ { single_track => { cd => 'mandatory_artwork' } },
+ { artist => { cds => 'mandatory_artwork'} },
+ ],
+ columns => {
+ cdid => 'cdid',
+ 'single_track.cd.mandatory_artwork.cd_id' => 'mandatory_artwork.cd_id',
+ 'artist.cds.mandatory_artwork.cd_id' => 'mandatory_artwork_2.cd_id',
+ },
+ },
+ )),
+ [[
+ { cdid => 3 },
+ {
+ single_track => [
+ undef,
+ { cd => [
+ undef,
+ { mandatory_artwork => [ { cd_id => 2 } ] }
+ ] }
+ ],
+ artist => [
+ undef,
+ { cds => [
+ [
+ undef,
+ { mandatory_artwork => [ { cd_id => 2 } ] }
+ ]
+ ] },
+ ],
+ }
+ ]],
+ );
}
sub null_branch {