use warnings;
use Test::More;
-use Test::Warn;
+use Test::Deep;
use lib qw(t/lib);
use DBICTest;
-my $new_collapser_version = DBIx::Class::ResultSet->can('_construct_objects');
-
my $schema = DBICTest->init_schema(no_populate => 1);
$schema->resultset('Artist')->create({ name => 'JMJ', cds => [{
sub inflate_result { [@_[2,3]] };
}
-warnings_exist
- { $schema->resultset ('CD')->search ({}, { result_class => 'DBICTest::_IRCapture', prefetch => 'tracks' } )->all }
- qr/\QResultClass DBICTest::_IRCapture does not inherit from DBIx::Class::Row and therefore its inflate_result() will receive the full prefetched data tree, without any branch definedness checks/,
- 'Legacy inflate_result() API warned',
-if $new_collapser_version;
-
cmp_structures(
([$schema->resultset ('CD')->search ({}, {
result_class => 'DBICTest::_IRCapture',
[
[
{ cdid => 1, single_track => undef, artist => 1, genreid => 1, year => 1981, title => "Magnetic Fields" },
- { single_track => [
+ { single_track => bless( [
{ trackid => undef, title => undef, position => undef, cd => undef, last_updated_at => undef, last_updated_on => undef },
- { cd => [
+ { cd => bless ( [
{ cdid => undef, single_track => undef, artist => undef, genreid => undef, year => undef, title => undef },
{
- artist => [
+ artist => bless ( [
{ artistid => undef, name => undef, charfield => undef, rank => undef }
- ]
+ ], $DBIx::Class::ResultSource::RowParser::Util::null_branch_class )
}
- ] }
- ] }
+ ], $DBIx::Class::ResultSource::RowParser::Util::null_branch_class ) }
+ ], $DBIx::Class::ResultSource::RowParser::Util::null_branch_class ) }
],
[
{ cdid => 2, single_track => undef, artist => 1, genreid => undef, year => 1976, title => "Oxygene" },
- { single_track => [
+ { single_track => bless( [
{ trackid => undef, title => undef, position => undef, cd => undef, last_updated_at => undef, last_updated_on => undef },
- { cd => [
+ { cd => bless ( [
{ cdid => undef, single_track => undef, artist => undef, genreid => undef, year => undef, title => undef },
{
- artist => [
+ artist => bless ( [
{ artistid => undef, name => undef, charfield => undef, rank => undef }
- ]
+ ], $DBIx::Class::ResultSource::RowParser::Util::null_branch_class )
}
- ] }
- ] }
+ ], $DBIx::Class::ResultSource::RowParser::Util::null_branch_class ) }
+ ], $DBIx::Class::ResultSource::RowParser::Util::null_branch_class ) }
],
[
{ cdid => 3, single_track => 6, artist => 1, genreid => 1, year => 1978, title => "Equinoxe" },
],
[
{ cdid => 4, single_track => undef, artist => 1, genreid => undef, year => 1977, title => "fuzzy_1" },
- { single_track => [
+ { single_track => bless( [
{ trackid => undef, title => undef, position => undef, cd => undef, last_updated_at => undef, last_updated_on => undef },
- { cd => [
+ { cd => bless ( [
{ cdid => undef, single_track => undef, artist => undef, genreid => undef, year => undef, title => undef },
{
- artist => [
+ artist => bless ( [
{ artistid => undef, name => undef, charfield => undef, rank => undef }
- ]
- }
- ] }
- ] }
- ],
- ],
- 'Simple 1:1 descend with classic prefetch legacy'
-);
-
-cmp_structures(
- ([$schema->resultset ('CD')->search ({}, {
- result_class => 'DBICTest::_IRCaptureAround',
- prefetch => { single_track => { cd => 'artist' } },
- order_by => 'me.cdid',
- })->all]),
- [
- [
- { cdid => 1, single_track => undef, artist => 1, genreid => 1, year => 1981, title => "Magnetic Fields" },
- { single_track => [] }
- ],
- [
- { cdid => 2, single_track => undef, artist => 1, genreid => undef, year => 1976, title => "Oxygene" },
- { single_track => [] }
- ],
- [
- { cdid => 3, single_track => 6, artist => 1, genreid => 1, year => 1978, title => "Equinoxe" },
- { single_track => [
- { trackid => 6, title => 'o1', position => 1, cd => 2, last_updated_at => undef, last_updated_on => undef },
- { cd => [
- { cdid => 2, single_track => undef, artist => 1, genreid => undef, year => 1976, title => "Oxygene" },
- {
- artist => [
- { artistid => 1, name => 'JMJ', charfield => undef, rank => 13 }
- ]
+ ], $DBIx::Class::ResultSource::RowParser::Util::null_branch_class )
}
- ] }
- ] }
- ],
- [
- { cdid => 4, single_track => undef, artist => 1, genreid => undef, year => 1977, title => "fuzzy_1" },
- { single_track => [ ] }
+ ], $DBIx::Class::ResultSource::RowParser::Util::null_branch_class ) }
+ ], $DBIx::Class::ResultSource::RowParser::Util::null_branch_class ) }
],
],
- 'Simple 1:1 descend with classic prefetch pruning'
+ 'Simple 1:1 descend with classic prefetch'
);
-
cmp_structures(
[$schema->resultset ('CD')->search ({}, {
result_class => 'DBICTest::_IRCapture',
[
[
{ artist => 1, genreid => 1, year => 1981, title => "Magnetic Fields" },
- { single_track => [
+ { single_track => bless( [
undef,
{ cd => [
undef,
]
}
] }
- ] }
+ ], $DBIx::Class::ResultSource::RowParser::Util::null_branch_class ) }
],
[
{ artist => 1, genreid => undef, year => 1976, title => "Oxygene" },
- { single_track => [
+ { single_track => bless( [
undef,
{ cd => [
undef,
]
}
] }
- ] }
+ ], $DBIx::Class::ResultSource::RowParser::Util::null_branch_class ) }
],
[
{ artist => 1, genreid => 1, year => 1978, title => "Equinoxe" },
],
[
{ artist => 1, genreid => undef, year => 1977, title => "fuzzy_1" },
- { single_track => [
+ { single_track => bless( [
undef,
{ cd => [
undef,
]
}
] }
- ] }
- ],
- ],
- 'Simple 1:1 descend with missing selectors legacy'
-);
-
-cmp_structures(
- [$schema->resultset ('CD')->search ({}, {
- result_class => 'DBICTest::_IRCaptureAround',
- join => { single_track => { cd => 'artist' } },
- columns => [
- { 'year' => 'me.year' },
- { 'genreid' => 'me.genreid' },
- { 'single_track.cd.artist.artistid' => 'artist.artistid' },
- { 'title' => 'me.title' },
- { 'artist' => 'me.artist' },
- ],
- order_by => 'me.cdid',
- })->all],
- [
- [
- { artist => 1, genreid => 1, year => 1981, title => "Magnetic Fields" },
- { single_track => [] }
- ],
- [
- { artist => 1, genreid => undef, year => 1976, title => "Oxygene" },
- { single_track => [ ] }
- ],
- [
- { artist => 1, genreid => 1, year => 1978, title => "Equinoxe" },
- { single_track => [
- undef,
- { cd => [
- undef,
- {
- artist => [
- { artistid => 1 }
- ]
- }
- ] }
- ] }
- ],
- [
- { artist => 1, genreid => undef, year => 1977, title => "fuzzy_1" },
- { single_track => [] }
+ ], $DBIx::Class::ResultSource::RowParser::Util::null_branch_class ) }
],
],
- 'Simple 1:1 descend with missing selectors pruning'
+ 'Simple 1:1 descend with missing selectors'
);
cmp_structures(
[
[
{ cdid => 1, single_track => undef, artist => 1, genreid => 1, year => 1981, title => "Magnetic Fields" },
- { single_track => [
+ { single_track => bless( [
{ trackid => undef, title => undef, position => undef, cd => undef, last_updated_at => undef, last_updated_on => undef },
{ cd => [
{ cdid => undef, single_track => undef, artist => undef, genreid => undef, year => undef, title => undef },
{
artist => [
{ artistid => undef, name => undef, charfield => undef, rank => undef },
- { cds => [ [
+ { cds => bless( [ [
{ cdid => undef, single_track => undef, artist => undef, genreid => undef, year => undef, title => undef },
- { tracks => [ [
+ { tracks => bless( [ [
{ trackid => undef, title => undef, position => undef, cd => undef, last_updated_at => undef, last_updated_on => undef },
- ] ] },
- ]]},
+ ] ], $DBIx::Class::ResultSource::RowParser::Util::null_branch_class ) },
+ ] ], $DBIx::Class::ResultSource::RowParser::Util::null_branch_class ) },
],
},
] },
- ] },
+ ], $DBIx::Class::ResultSource::RowParser::Util::null_branch_class ) },
],
[
{ cdid => 2, single_track => undef, artist => 1, genreid => undef, year => 1976, title => "Oxygene" },
- { single_track => [
+ { single_track => bless( [
{ trackid => undef, title => undef, position => undef, cd => undef, last_updated_at => undef, last_updated_on => undef },
{ cd => [
{ cdid => undef, single_track => undef, artist => undef, genreid => undef, year => undef, title => undef },
{
artist => [
{ artistid => undef, name => undef, charfield => undef, rank => undef },
- { cds => [ [
+ { cds => bless( [ [
{ cdid => undef, single_track => undef, artist => undef, genreid => undef, year => undef, title => undef },
- { tracks => [ [
+ { tracks => bless( [ [
{ trackid => undef, title => undef, position => undef, cd => undef, last_updated_at => undef, last_updated_on => undef },
- ] ] },
- ]]},
- ]
- }
- ] }
- ] }
+ ] ], $DBIx::Class::ResultSource::RowParser::Util::null_branch_class ) },
+ ] ], $DBIx::Class::ResultSource::RowParser::Util::null_branch_class ) },
+ ],
+ },
+ ] },
+ ], $DBIx::Class::ResultSource::RowParser::Util::null_branch_class ) },
],
[
{ cdid => 3, single_track => 6, artist => 1, genreid => 1, year => 1978, title => "Equinoxe" },
{ cds => [
[
{ cdid => 4, single_track => undef, artist => 1, genreid => undef, year => 1977, title => "fuzzy_1" },
- { tracks => [
+ { tracks => bless( [
[ { trackid => undef, title => undef, position => undef, cd => undef, last_updated_at => undef, last_updated_on => undef } ],
- ] },
+ ], $DBIx::Class::ResultSource::RowParser::Util::null_branch_class ) },
],
[
{ cdid => 1, single_track => undef, artist => 1, genreid => 1, year => 1981, title => "Magnetic Fields" },
],
[
{ cdid => 4, single_track => undef, artist => 1, genreid => undef, year => 1977, title => "fuzzy_1" },
- { single_track => [
+ { single_track => bless( [
{ trackid => undef, title => undef, position => undef, cd => undef, last_updated_at => undef, last_updated_on => undef },
{ cd => [
{ cdid => undef, single_track => undef, artist => undef, genreid => undef, year => undef, title => undef },
{
artist => [
{ artistid => undef, name => undef, charfield => undef, rank => undef },
- { cds => [ [
+ { cds => bless( [ [
{ cdid => undef, single_track => undef, artist => undef, genreid => undef, year => undef, title => undef },
- { tracks => [ [
+ { tracks => bless( [ [
{ trackid => undef, title => undef, position => undef, cd => undef, last_updated_at => undef, last_updated_on => undef },
- ] ] },
- ]]},
- ]
- }
- ] }
- ] }
- ],
- ],
- 'Collapsing 1:1 ending in chained has_many with classic prefetch legacy'
-);
-
-cmp_structures(
- ([$schema->resultset ('CD')->search ({}, {
- result_class => 'DBICTest::_IRCaptureAround',
- prefetch => [ { single_track => { cd => { artist => { cds => 'tracks' } } } } ],
- order_by => [qw/me.cdid tracks.trackid/],
- })->all]),
- [
- [
- { cdid => 1, single_track => undef, artist => 1, genreid => 1, year => 1981, title => "Magnetic Fields" },
- { single_track => [ ] },
- ],
- [
- { cdid => 2, single_track => undef, artist => 1, genreid => undef, year => 1976, title => "Oxygene" },
- { single_track => [ ] },
- ],
- [
- { cdid => 3, single_track => 6, artist => 1, genreid => 1, year => 1978, title => "Equinoxe" },
- { single_track => [
- { trackid => 6, title => 'o1', position => 1, cd => 2, last_updated_at => undef, last_updated_on => undef },
- { cd => [
- { cdid => 2, single_track => undef, artist => 1, genreid => undef, year => 1976, title => "Oxygene" },
- {
- artist => [
- { artistid => 1, name => 'JMJ', charfield => undef, rank => 13 },
- { cds => [
- [
- { cdid => 4, single_track => undef, artist => 1, genreid => undef, year => 1977, title => "fuzzy_1" },
- { tracks => [ ] },
- ],
- [
- { cdid => 1, single_track => undef, artist => 1, genreid => 1, year => 1981, title => "Magnetic Fields" },
- { tracks => [
- [ { trackid => 1, title => 'm1', position => 1, cd => 1, last_updated_at => undef, last_updated_on => undef } ],
- [ { trackid => 2, title => 'm2', position => 2, cd => 1, last_updated_at => undef, last_updated_on => undef } ],
- [ { trackid => 3, title => 'm3', position => 3, cd => 1, last_updated_at => undef, last_updated_on => undef } ],
- [ { trackid => 4, title => 'm4', position => 4, cd => 1, last_updated_at => undef, last_updated_on => undef } ],
- ]},
- ],
- [
- { cdid => 2, single_track => undef, artist => 1, genreid => undef, year => 1976, title => "Oxygene" },
- { tracks => [
- [ { trackid => 5, title => 'o2', position => 2, cd => 2, last_updated_at => undef, last_updated_on => undef } ],
- [ { trackid => 6, title => 'o1', position => 1, cd => 2, last_updated_at => undef, last_updated_on => undef } ],
- ]},
- ],
- [
- { cdid => 3, single_track => 6, artist => 1, genreid => 1, year => 1978, title => "Equinoxe" },
- { tracks => [
- [ { trackid => 7, title => 'e1', position => 1, cd => 3, last_updated_at => undef, last_updated_on => undef } ],
- [ { trackid => 8, title => 'e2', position => 2, cd => 3, last_updated_at => undef, last_updated_on => undef } ],
- [ { trackid => 9, title => 'e3', position => 3, cd => 3, last_updated_at => undef, last_updated_on => undef } ],
- ]},
- ],
- ]},
- ]
- }
- ] }
- ] }
- ],
- [
- { cdid => 4, single_track => undef, artist => 1, genreid => undef, year => 1977, title => "fuzzy_1" },
- { single_track => [ ] },
+ ] ], $DBIx::Class::ResultSource::RowParser::Util::null_branch_class ) },
+ ] ], $DBIx::Class::ResultSource::RowParser::Util::null_branch_class ) },
+ ],
+ },
+ ] },
+ ], $DBIx::Class::ResultSource::RowParser::Util::null_branch_class ) },
],
],
- 'Collapsing 1:1 ending in chained has_many with classic prefetch pruning'
+ 'Collapsing 1:1 ending in chained has_many with classic prefetch'
);
cmp_structures (
{ artistid => 1, name => 'JMJ', charfield => undef, rank => 13 },
{ cds => [
{ cdid => 4, single_track => undef, artist => 1, genreid => undef, year => 1977, title => "fuzzy_1" },
- { tracks => [
+ { tracks => bless( [
{ trackid => undef, title => undef, position => undef, cd => undef, last_updated_at => undef, last_updated_on => undef },
- ]},
- ]},
- ],
- ],
- 'Non-Collapsing chained has_many legacy'
-);
-
-cmp_structures(
- ([$schema->resultset ('Artist')->search ({}, {
- result_class => 'DBICTest::_IRCaptureAround',
- join => { cds => 'tracks' },
- '+columns' => [
- (map { "cds.$_" } $schema->source('CD')->columns),
- (map { +{ "cds.tracks.$_" => "tracks.$_" } } $schema->source('Track')->columns),
- ],
- order_by => [qw/cds.cdid tracks.trackid/],
- })->all]),
- [
- [
- { artistid => 1, name => 'JMJ', charfield => undef, rank => 13 },
- { cds => [
- { cdid => 1, single_track => undef, artist => 1, genreid => 1, year => 1981, title => "Magnetic Fields" },
- { tracks => [
- { trackid => 1, title => 'm1', position => 1, cd => 1, last_updated_at => undef, last_updated_on => undef },
- ]},
- ]},
- ],
- [
- { artistid => 1, name => 'JMJ', charfield => undef, rank => 13 },
- { cds => [
- { cdid => 1, single_track => undef, artist => 1, genreid => 1, year => 1981, title => "Magnetic Fields" },
- { tracks => [
- { trackid => 2, title => 'm2', position => 2, cd => 1, last_updated_at => undef, last_updated_on => undef },
- ]},
- ]},
- ],
- [
- { artistid => 1, name => 'JMJ', charfield => undef, rank => 13 },
- { cds => [
- { cdid => 1, single_track => undef, artist => 1, genreid => 1, year => 1981, title => "Magnetic Fields" },
- { tracks => [
- { trackid => 3, title => 'm3', position => 3, cd => 1, last_updated_at => undef, last_updated_on => undef },
- ]},
- ]},
- ],
- [
- { artistid => 1, name => 'JMJ', charfield => undef, rank => 13 },
- { cds => [
- { cdid => 1, single_track => undef, artist => 1, genreid => 1, year => 1981, title => "Magnetic Fields" },
- { tracks => [
- { trackid => 4, title => 'm4', position => 4, cd => 1, last_updated_at => undef, last_updated_on => undef },
- ]},
- ]},
- ],
- [
- { artistid => 1, name => 'JMJ', charfield => undef, rank => 13 },
- { cds => [
- { cdid => 2, single_track => undef, artist => 1, genreid => undef, year => 1976, title => "Oxygene" },
- { tracks => [
- { trackid => 5, title => 'o2', position => 2, cd => 2, last_updated_at => undef, last_updated_on => undef },
- ]},
- ]},
- ],
- [
- { artistid => 1, name => 'JMJ', charfield => undef, rank => 13 },
- { cds => [
- { cdid => 2, single_track => undef, artist => 1, genreid => undef, year => 1976, title => "Oxygene" },
- { tracks => [
- { trackid => 6, title => 'o1', position => 1, cd => 2, last_updated_at => undef, last_updated_on => undef },
- ]},
- ]},
- ],
- [
- { artistid => 1, name => 'JMJ', charfield => undef, rank => 13 },
- { cds => [
- { cdid => 3, single_track => 6, artist => 1, genreid => 1, year => 1978, title => "Equinoxe" },
- { tracks => [
- { trackid => 7, title => 'e1', position => 1, cd => 3, last_updated_at => undef, last_updated_on => undef },
- ]},
- ]},
- ],
- [
- { artistid => 1, name => 'JMJ', charfield => undef, rank => 13 },
- { cds => [
- { cdid => 3, single_track => 6, artist => 1, genreid => 1, year => 1978, title => "Equinoxe" },
- { tracks => [
- { trackid => 8, title => 'e2', position => 2, cd => 3, last_updated_at => undef, last_updated_on => undef },
- ]},
- ]},
- ],
- [
- { artistid => 1, name => 'JMJ', charfield => undef, rank => 13 },
- { cds => [
- { cdid => 3, single_track => 6, artist => 1, genreid => 1, year => 1978, title => "Equinoxe" },
- { tracks => [
- { trackid => 9, title => 'e3', position => 3, cd => 3, last_updated_at => undef, last_updated_on => undef },
- ]},
- ]},
- ],
- [
- { artistid => 1, name => 'JMJ', charfield => undef, rank => 13 },
- { cds => [
- { cdid => 4, single_track => undef, artist => 1, genreid => undef, year => 1977, title => "fuzzy_1" },
- { tracks => [ ] },
+ ], $DBIx::Class::ResultSource::RowParser::Util::null_branch_class ) },
]},
],
],
- 'Non-Collapsing chained has_many pruning'
+ 'Non-Collapsing chained has_many'
);
sub cmp_structures {
my ($left, $right, $msg) = @_;
- local $TODO = "Pruning test won't work on pre-rewrite DBIC"
- if ($msg||'') =~ /pruning$/ and ! $new_collapser_version;
-
local $Test::Builder::Level = $Test::Builder::Level + 1;
- is_deeply($left, $right, $msg||());
+ cmp_deeply($left, $right, $msg||());
}
done_testing;
}),
'$_ = [
{ year => $_->[1] },
- { single_track => [
- undef,
- { cd => [
+ { single_track => ( ! defined( $_->[0]) )
+ ? bless( [
undef,
- { artist => [
- { name => $_->[0] },
+ { cd => [
+ undef,
+ { artist => [
+ { name => $_->[0] },
+ ] },
] },
- ]},
- ]},
+ ], __NBC__ )
+ : [
+ undef,
+ { cd => [
+ undef,
+ { artist => [
+ { name => $_->[0] },
+ ] },
+ ] },
+ ]
+ },
] for @{$_[0]}',
'Simple 1:1 descending non-collapsing parser',
);
title
artist
/];
-is_same_src (
- $schema->source ('CD')->_mk_row_parser({
- inflate_map => $infmap,
- }),
- '$_ = [
- { artist => $_->[5], title => $_->[4], year => $_->[2] },
- { single_track => [
- undef,
- { cd => [
- undef,
- { artist => [
- { artistid => $_->[1] },
- { cds => [
- { cdid => $_->[3] },
- { tracks => [
- { title => $_->[0] }
- ] },
- ] },
- ] },
- ] },
- ] },
- ] for @{$_[0]}',
- '1:1 descending non-collapsing parser terminating with chained 1:M:M',
-);
is_same_src (
$schema->source ('CD')->_mk_row_parser({
- prune_null_branches => 1,
inflate_map => $infmap,
}),
'$_ = [
{ artist => $_->[5], title => $_->[4], year => $_->[2] },
{
- ( (! defined $_->[0] ) && (! defined $_->[1]) && (! defined $_->[3] ) )
- ? ( single_track => [] )
- : ( single_track => [
+ single_track => ( (! defined $_->[0] ) && (! defined $_->[1]) && (! defined $_->[3] ) )
+ ? bless( [
+ undef,
+ {
+ cd => [
+ undef,
+ {
+ artist => [
+ { artistid => $_->[1] },
+ {
+ cds => ( (! defined $_->[0] ) && ( ! defined $_->[3] ) )
+ ? bless ([
+ { cdid => $_->[3] },
+ {
+ tracks => ( ! defined $_->[0] )
+ ? bless ( [{ title => $_->[0] }], __NBC__ )
+ : [{ title => $_->[0] }]
+ }
+ ], __NBC__)
+ : [
+ { cdid => $_->[3] },
+ {
+ tracks => ( ! defined $_->[0] )
+ ? bless ( [{ title => $_->[0] }], __NBC__ )
+ : [{ title => $_->[0] }]
+ }
+ ]
+ }
+ ]
+ }
+ ]
+ }
+ ], __NBC__)
+ : [
undef,
{
cd => [
artist => [
{ artistid => $_->[1] },
{
- ( (! defined $_->[0] ) && ( ! defined $_->[3] ) )
- ? ( cds => [] )
- : ( cds => [
+ cds => ( (! defined $_->[0] ) && ( ! defined $_->[3] ) )
+ ? bless ([
+ { cdid => $_->[3] },
+ {
+ tracks => ( ! defined $_->[0] )
+ ? bless ( [{ title => $_->[0] }], __NBC__ )
+ : [{ title => $_->[0] }]
+ }
+ ], __NBC__)
+ : [
{ cdid => $_->[3] },
{
- ( ! defined $_->[0] )
- ? ( tracks => [] )
- : ( tracks => [{ title => $_->[0] }] )
+ tracks => ( ! defined $_->[0] )
+ ? bless ( [{ title => $_->[0] }], __NBC__ )
+ : [{ title => $_->[0] }]
}
- ])
+ ]
}
]
}
]
}
- ])
+ ]
}
] for @{$_[0]}',
- '1:1 descending non-collapsing null-pruning parser terminating with chained 1:M:M',
+ '1:1 descending non-collapsing parser terminating with chained 1:M:M',
);
is_same_src (
$schema->source ('CD')->_mk_row_parser({
- prune_null_branches => 1,
hri_style => 1,
inflate_map => $infmap,
}),
'$_ = {
artist => $_->[5], title => $_->[4], year => $_->[2],
- ( (! defined $_->[0] ) && (! defined $_->[1]) && (! defined $_->[3] ) )
- ? ( single_track => undef )
- : ( single_track => {
+ ( single_track => ( (! defined $_->[0] ) && (! defined $_->[1]) && (! defined $_->[3] ) )
+ ? undef
+ : {
cd =>
{
artist => {
artistid => $_->[1],
- ( (! defined $_->[0] ) && ( ! defined $_->[3] ) )
- ? ( cds => undef )
- : ( cds => {
+ ( cds => ( (! defined $_->[0] ) && ( ! defined $_->[3] ) )
+ ? undef
+ : {
cdid => $_->[3],
- ( ! defined $_->[0] )
- ? ( tracks => undef )
- : ( tracks => { title => $_->[0] } )
+ ( tracks => ( ! defined $_->[0] )
+ ? undef
+ : { title => $_->[0] }
+ )
}
- )
+ )
}
}
}
- )
+ )
} for @{$_[0]}',
- '1:1 descending non-collapsing null-pruning HRI-direct parser terminating with chained 1:M:M',
+ '1:1 descending non-collapsing HRI-direct parser terminating with chained 1:M:M',
);
$collapse_idx[0]{$cur_row_ids{4}}{$cur_row_ids{5}} ||= [{ artist => $cur_row_data->[5], title => $cur_row_data->[4], year => $cur_row_data->[2] }];
# prefetch data of single_track (placed in root)
- $collapse_idx[0]{$cur_row_ids{4}}{$cur_row_ids{5}}[1]{single_track} ||= $collapse_idx[1]{$cur_row_ids{1}}{$cur_row_ids{4}}{$cur_row_ids{5}};
+ $collapse_idx[0]{$cur_row_ids{4}}{$cur_row_ids{5}}[1]{single_track} ||= $collapse_idx[1]{$cur_row_ids{1}}{$cur_row_ids{4}}{$cur_row_ids{5}} ||= [];
+ defined($cur_row_data->[1]) or bless( $collapse_idx[0]{$cur_row_ids{4}}{$cur_row_ids{5}}[1]{single_track}, __NBC__ );
# prefetch data of cd (placed in single_track)
- $collapse_idx[1]{$cur_row_ids{1}}{$cur_row_ids{4}}{$cur_row_ids{5}}[1]{cd} ||= $collapse_idx[2]{$cur_row_ids{1}}{$cur_row_ids{4}}{$cur_row_ids{5}};
+ $collapse_idx[1]{$cur_row_ids{1}}{$cur_row_ids{4}}{$cur_row_ids{5}}[1]{cd} ||= $collapse_idx[2]{$cur_row_ids{1}}{$cur_row_ids{4}}{$cur_row_ids{5}} ||= [];
# prefetch data of artist ( placed in single_track->cd)
$collapse_idx[2]{$cur_row_ids{1}}{$cur_row_ids{4}}{$cur_row_ids{5}}[1]{artist} ||= $collapse_idx[3]{$cur_row_ids{1}}{$cur_row_ids{4}}{$cur_row_ids{5}} ||= [{ artistid => $cur_row_data->[1] }];
push @{$collapse_idx[3]{$cur_row_ids{1}}{$cur_row_ids{4}}{$cur_row_ids{5}}[1]{cds}}, (
$collapse_idx[4]{$cur_row_ids{1}}{$cur_row_ids{3}}{$cur_row_ids{4}}{$cur_row_ids{5}} = [{ cdid => $cur_row_data->[3] }]
);
+ defined($cur_row_data->[3]) or bless( $collapse_idx[3]{$cur_row_ids{1}}{$cur_row_ids{4}}{$cur_row_ids{5}}[1]{cds}, __NBC__ );
# prefetch data of tracks (if available)
(! $collapse_idx[5]{$cur_row_ids{0}}{$cur_row_ids{1}}{$cur_row_ids{3}}{$cur_row_ids{4}}{$cur_row_ids{5}} )
push @{$collapse_idx[4]{$cur_row_ids{1}}{$cur_row_ids{3}}{$cur_row_ids{4}}{$cur_row_ids{5}}[1]{tracks}}, (
$collapse_idx[5]{$cur_row_ids{0}}{$cur_row_ids{1}}{$cur_row_ids{3}}{$cur_row_ids{4}}{$cur_row_ids{5}} = [{ title => $cur_row_data->[0] }]
);
+ defined($cur_row_data->[0]) or bless( $collapse_idx[4]{$cur_row_ids{1}}{$cur_row_ids{3}}{$cur_row_ids{4}}{$cur_row_ids{5}}[1]{tracks}, __NBC__ );
$_[0][$result_pos++] = $collapse_idx[0]{$cur_row_ids{4}}{$cur_row_ids{5}}
if $is_new_res;
$schema->source ('CD')->_mk_row_parser({
inflate_map => $infmap,
collapse => 1,
- prune_null_branches => 1,
hri_style => 1,
}),
' my($rows_pos, $result_pos, $cur_row_data, %cur_row_ids, @collapse_idx, $is_new_res) = (0, 0);
}
splice @{$_[0]}, $result_pos;
',
- 'Same 1:1 descending terminating with chained 1:M:M but with collapse, pruning, hri-style',
+ 'Same 1:1 descending terminating with chained 1:M:M but with collapse, HRI-direct',
);
$infmap = [qw/
$collapse_idx[0]{$cur_row_ids{1}} ||= [{ genreid => $cur_row_data->[4], latest_cd => $cur_row_data->[7], year => $cur_row_data->[3] }];
- $collapse_idx[0]{$cur_row_ids{1}}[1]{existing_single_track} ||= $collapse_idx[1]{$cur_row_ids{1}};
- $collapse_idx[1]{$cur_row_ids{1}}[1]{cd} ||= $collapse_idx[2]{$cur_row_ids{1}};
+ $collapse_idx[0]{$cur_row_ids{1}}[1]{existing_single_track} ||= $collapse_idx[1]{$cur_row_ids{1}} ||= [];
+ $collapse_idx[1]{$cur_row_ids{1}}[1]{cd} ||= $collapse_idx[2]{$cur_row_ids{1}} ||= [];
$collapse_idx[2]{$cur_row_ids{1}}[1]{artist} ||= $collapse_idx[3]{$cur_row_ids{1}} ||= [{ artistid => $cur_row_data->[1] }];
(! $collapse_idx[4]{$cur_row_ids{1}}{$cur_row_ids{6}} )
push @{ $collapse_idx[3]{$cur_row_ids{1}}[1]{cds} }, (
$collapse_idx[4]{$cur_row_ids{1}}{$cur_row_ids{6}} = [{ cdid => $cur_row_data->[6], genreid => $cur_row_data->[9], year => $cur_row_data->[2] }]
);
+ defined($cur_row_data->[6]) or bless( $collapse_idx[3]{$cur_row_ids{1}}[1]{cds}, __NBC__ );
(! $collapse_idx[5]{$cur_row_ids{1}}{$cur_row_ids{6}}{$cur_row_ids{8}} )
and
push @{ $collapse_idx[4]{$cur_row_ids{1}}{$cur_row_ids{6}}[1]{tracks} }, (
$collapse_idx[5]{$cur_row_ids{1}}{$cur_row_ids{6}}{$cur_row_ids{8}} = [{ title => $cur_row_data->[8] }]
);
+ defined($cur_row_data->[8]) or bless( $collapse_idx[4]{$cur_row_ids{1}}{$cur_row_ids{6}}[1]{tracks}, __NBC__ );
(! $collapse_idx[6]{$cur_row_ids{1}}{$cur_row_ids{5}} )
and
push @{ $collapse_idx[0]{$cur_row_ids{1}}[1]{tracks} }, (
$collapse_idx[6]{$cur_row_ids{1}}{$cur_row_ids{5}} = [{ title => $cur_row_data->[5] }]
);
+ defined($cur_row_data->[5]) or bless( $collapse_idx[0]{$cur_row_ids{1}}[1]{tracks}, __NBC__ );
- $collapse_idx[6]{$cur_row_ids{1}}{$cur_row_ids{5}}[1]{lyrics} ||= $collapse_idx[7]{$cur_row_ids{1}}{$cur_row_ids{5}}{$cur_row_ids{10}};
+ $collapse_idx[6]{$cur_row_ids{1}}{$cur_row_ids{5}}[1]{lyrics} ||= $collapse_idx[7]{$cur_row_ids{1}}{$cur_row_ids{5}}{$cur_row_ids{10}} ||= [];
+ defined($cur_row_data->[10]) or bless( $collapse_idx[6]{$cur_row_ids{1}}{$cur_row_ids{5}}[1]{lyrics}, __NBC__ );
(! $collapse_idx[8]{$cur_row_ids{0}}{$cur_row_ids{1}}{$cur_row_ids{5}}{$cur_row_ids{10}} )
and
$schema->source ('CD')->_mk_row_parser({
inflate_map => $infmap,
collapse => 1,
- prune_null_branches => 1,
}),
' my ($rows_pos, $result_pos, $cur_row_data, %cur_row_ids, @collapse_idx, $is_new_res) = (0,0);
$collapse_idx[0]{$cur_row_ids{1}} ||= [{ genreid => $cur_row_data->[4], latest_cd => $cur_row_data->[7], year => $cur_row_data->[3] }];
- $collapse_idx[0]{$cur_row_ids{1}}[1]{existing_single_track} ||= $collapse_idx[1]{$cur_row_ids{1}};
- $collapse_idx[1]{$cur_row_ids{1}}[1]{cd} ||= $collapse_idx[2]{$cur_row_ids{1}};
+ $collapse_idx[0]{$cur_row_ids{1}}[1]{existing_single_track} ||= $collapse_idx[1]{$cur_row_ids{1}} ||= [];
+ $collapse_idx[1]{$cur_row_ids{1}}[1]{cd} ||= $collapse_idx[2]{$cur_row_ids{1}} ||= [];
$collapse_idx[2]{$cur_row_ids{1}}[1]{artist} ||= $collapse_idx[3]{$cur_row_ids{1}} ||= [{ artistid => $cur_row_data->[1] }];
- (defined $cur_row_data->[6])
- and
(! $collapse_idx[4]{$cur_row_ids{1}}{$cur_row_ids{6}} )
and
push @{ $collapse_idx[3]{$cur_row_ids{1}}[1]{cds} }, (
$collapse_idx[4]{$cur_row_ids{1}}{$cur_row_ids{6}} = [{ cdid => $cur_row_data->[6], genreid => $cur_row_data->[9], year => $cur_row_data->[2] }]
);
- $collapse_idx[3]{$cur_row_ids{1}}[1]{cds} ||= [];
+ defined($cur_row_data->[6]) or bless( $collapse_idx[3]{$cur_row_ids{1}}[1]{cds}, __NBC__ );
- (defined $cur_row_data->[8])
- and
(! $collapse_idx[5]{$cur_row_ids{1}}{$cur_row_ids{6}}{$cur_row_ids{8}} )
and
push @{ $collapse_idx[4]{$cur_row_ids{1}}{$cur_row_ids{6}}[1]{tracks} }, (
$collapse_idx[5]{$cur_row_ids{1}}{$cur_row_ids{6}}{$cur_row_ids{8}} = [{ title => $cur_row_data->[8] }]
);
- $collapse_idx[4]{$cur_row_ids{1}}{$cur_row_ids{6}}[1]{tracks} ||= [];
+ defined($cur_row_data->[8]) or bless( $collapse_idx[4]{$cur_row_ids{1}}{$cur_row_ids{6}}[1]{tracks}, __NBC__ );
- (defined $cur_row_data->[5])
- and
(! $collapse_idx[6]{$cur_row_ids{1}}{$cur_row_ids{5}} )
and
push @{ $collapse_idx[0]{$cur_row_ids{1}}[1]{tracks} }, (
$collapse_idx[6]{$cur_row_ids{1}}{$cur_row_ids{5}} = [{ title => $cur_row_data->[5] }]
);
- $collapse_idx[0]{$cur_row_ids{1}}[1]{tracks} ||= [];
+ defined($cur_row_data->[5]) or bless( $collapse_idx[0]{$cur_row_ids{1}}[1]{tracks}, __NBC__ );
- (defined $cur_row_data->[10])
- and
- $collapse_idx[6]{$cur_row_ids{1}}{$cur_row_ids{5}}[1]{lyrics} ||= $collapse_idx[7]{$cur_row_ids{1}}{$cur_row_ids{5}}{$cur_row_ids{10}};
- $collapse_idx[6]{$cur_row_ids{1}}{$cur_row_ids{5}}[1]{lyrics} ||= [];
+ $collapse_idx[6]{$cur_row_ids{1}}{$cur_row_ids{5}}[1]{lyrics} ||= $collapse_idx[7]{$cur_row_ids{1}}{$cur_row_ids{5}}{$cur_row_ids{10}} ||= [];
+ defined($cur_row_data->[10]) or bless( $collapse_idx[6]{$cur_row_ids{1}}{$cur_row_ids{5}}[1]{lyrics}, __NBC__ );
- (defined $cur_row_data->[0])
- and
(! $collapse_idx[8]{$cur_row_ids{0}}{$cur_row_ids{1}}{$cur_row_ids{5}}{$cur_row_ids{10}} )
and
push @{ $collapse_idx[7]{$cur_row_ids{1}}{$cur_row_ids{5}}{$cur_row_ids{10}}[1]{existing_lyric_versions} }, (
$collapse_idx[8]{$cur_row_ids{0}}{$cur_row_ids{1}}{$cur_row_ids{5}}{$cur_row_ids{10}} = [{ lyric_id => $cur_row_data->[10], text => $cur_row_data->[0] }]
);
- $collapse_idx[7]{$cur_row_ids{1}}{$cur_row_ids{5}}{$cur_row_ids{10}}[1]{existing_lyric_versions} ||= [];
$_[0][$result_pos++] = $collapse_idx[0]{$cur_row_ids{1}}
if $is_new_res;
splice @{$_[0]}, $result_pos;
',
- 'Multiple has_many on multiple branches with branch pruning torture test',
+ 'Multiple has_many on multiple branches with branch torture test',
);
$infmap = [
$collapse_idx[0]{$cur_row_ids{10}} ||= [{ year => $$cur_row_data[1] }];
- $collapse_idx[0]{$cur_row_ids{10}}[1]{single_track} ||= ($collapse_idx[1]{$cur_row_ids{0}} ||= [{ trackid => $$cur_row_data[0] }]);
+ $collapse_idx[0]{$cur_row_ids{10}}[1]{single_track} ||= ($collapse_idx[1]{$cur_row_ids{0}} ||= [{ trackid => $cur_row_data->[0] }]);
+ defined($cur_row_data->[0]) or bless ( $collapse_idx[0]{$cur_row_ids{10}}[1]{single_track}, __NBC__ );
- $collapse_idx[1]{$cur_row_ids{0}}[1]{cd} ||= $collapse_idx[2]{$cur_row_ids{0}};
+ $collapse_idx[1]{$cur_row_ids{0}}[1]{cd} ||= $collapse_idx[2]{$cur_row_ids{0}} ||= [];
- $collapse_idx[2]{$cur_row_ids{0}}[1]{artist} ||= ($collapse_idx[3]{$cur_row_ids{0}} ||= [{ artistid => $$cur_row_data[6] }]);
+ $collapse_idx[2]{$cur_row_ids{0}}[1]{artist} ||= ($collapse_idx[3]{$cur_row_ids{0}} ||= [{ artistid => $cur_row_data->[6] }]);
(! $collapse_idx[4]{$cur_row_ids{0}}{$cur_row_ids{4}} )
and
push @{$collapse_idx[3]{$cur_row_ids{0}}[1]{cds}}, (
- $collapse_idx[4]{$cur_row_ids{0}}{$cur_row_ids{4}} = [{ cdid => $$cur_row_data[4], genreid => $$cur_row_data[7], year => $$cur_row_data[5] }]
+ $collapse_idx[4]{$cur_row_ids{0}}{$cur_row_ids{4}} = [{ cdid => $cur_row_data->[4], genreid => $cur_row_data->[7], year => $cur_row_data->[5] }]
);
+ defined($cur_row_data->[4]) or bless ( $collapse_idx[3]{$cur_row_ids{0}}[1]{cds}, __NBC__ );
(! $collapse_idx[5]{$cur_row_ids{0}}{$cur_row_ids{4}}{$cur_row_ids{8}} )
and
push @{$collapse_idx[4]{$cur_row_ids{0}}{$cur_row_ids{4}}[1]{tracks}}, (
- $collapse_idx[5]{$cur_row_ids{0}}{$cur_row_ids{4}}{$cur_row_ids{8}} = [{ title => $$cur_row_data[8] }]
+ $collapse_idx[5]{$cur_row_ids{0}}{$cur_row_ids{4}}{$cur_row_ids{8}} = [{ title => $cur_row_data->[8] }]
);
+ defined($cur_row_data->[8]) or bless ( $collapse_idx[4]{$cur_row_ids{0}}{$cur_row_ids{4}}[1]{tracks}, __NBC__ );
(! $collapse_idx[6]{$cur_row_ids{2}}{$cur_row_ids{3}} )
and
push @{$collapse_idx[0]{$cur_row_ids{10}}[1]{tracks}}, (
- $collapse_idx[6]{$cur_row_ids{2}}{$cur_row_ids{3}} = [{ cd => $$cur_row_data[2], title => $$cur_row_data[3] }]
+ $collapse_idx[6]{$cur_row_ids{2}}{$cur_row_ids{3}} = [{ cd => $$cur_row_data[2], title => $cur_row_data->[3] }]
);
+ defined($cur_row_data->[2]) or bless ( $collapse_idx[0]{$cur_row_ids{10}}[1]{tracks}, __NBC__ );
$_[0][$result_pos++] = $collapse_idx[0]{$cur_row_ids{10}}
if $is_new_res;
$schema->source ('CD')->_mk_row_parser({
inflate_map => $infmap,
collapse => 1,
- prune_null_branches => 1,
hri_style => 1,
}),
' my($rows_pos, $result_pos, $cur_row_data, %cur_row_ids, @collapse_idx, $is_new_res) = (0, 0);
splice @{$_[0]}, $result_pos;
',
- 'Multiple has_many on multiple branches with underdefined root, hri style with branch pruning torture test',
+ 'Multiple has_many on multiple branches with underdefined root, HRI-direct torture test',
);
done_testing;
$deparser ||= B::Deparse->new;
local $Test::Builder::Level = $Test::Builder::Level + 1;
- my ($got, $expect) = map {
+ my ($got, $expect) = @_;
+
+ $expect =~ s/__NBC__/B::perlstring($DBIx::Class::ResultSource::RowParser::Util::null_branch_class)/ge;
+
+ my @normalized = map {
my $cref = eval "sub { $_ }" or do {
fail "Coderef does not compile!\n\n$@\n\n$_";
return undef;
};
$deparser->coderef2text($cref);
- } @_[0,1];
-
-#use Test::Differences;
-#eq_or_diff($got, $expect);
-
- is ($got, $expect, $_[2]||() )
- or note ("Originals source:\n\n$_[0]\n\n$_[1]\n");
+ } ($got, $expect);
+
+ &is (@normalized, $_[2]||() ) or do {
+ eval { require Test::Differences }
+ ? &Test::Differences::eq_or_diff( @normalized, $_[2]||() )
+ : note ("Original sources:\n\n$got\n\n$expect\n");
+ BAIL_OUT('');
+ };
}
-