use strict;
-use warnings;
+use warnings;
use Test::More;
use Test::Exception;
my $schema = DBICTest->init_schema();
my $sdebug = $schema->storage->debug;
-
# once the following TODO is complete, remove the 2 warning tests immediately
# after the TODO block
# (the TODO block itself contains tests ensuring that the warns are removed)
is (@w, 1, 'warning on attempt prefetching several same level has_manys (M -> 1 -> M + M)');
}
+
+# Illustration purposes only
+
+{
+ package Inf::Dump;
+ sub inflate_result {
+ return [ @_[2,3] ];
+ }
+}
+
+my $cd = $schema->resultset ('CD')->create ({
+ artist => 1,
+ title => 'bad cd',
+ year => 1313,
+ tags => [ map { { tag => "bad tag $_" } } (1 .. 3) ],
+ tracks => [
+ { title => 'bad track 1', cd_single => {
+ artist => 1,
+ title => 'bad_single',
+ year => 1313,
+ }},
+ map { { title => "bad track $_" } } (2 .. 3),
+ ],
+});
+
+my $rs = $schema->resultset ('CD')->search (
+ { 'me.cdid' => $cd->id },
+ { prefetch => [ 'tags', { tracks => 'cd_single' } ], result_class => 'Inf::Dump' },
+);
+
+use Text::Table;
+my $query = ${$rs->as_query}->[0];
+my ($cols) = ( $query =~ /SELECT (.+) FROM/);
+my $tb = Text::Table->new (map { $_ => \ ' | ' } (split /,\s*/, $cols) );
+
+my $c = $rs->cursor;
+while (my @stuff = $c->next) {
+ $tb->add (map { defined $_ ? $_ : 'NULL' } (@stuff) );
+}
+
+$rs->reset;
+use Data::Dumper;
+note Dumper [
+ "\n$query",
+ "\n$tb",
+ $rs->next
+];
+
+
+
+
__END__
The solution is to rewrite ResultSet->_collapse_result() and
ResultSource->resolve_prefetch() to focus on the final results from the collapse