Subject: | Unclear error |
DBIx::Class::ResultSet::_resolved_attrs(): Unable to prefetch, resultset contains an unnamed selector {exists => \["(SELECT 1 FROM \"service_package_set\" \"partial\" WHERE ( ( \"service_type_id_covered\" = \"ServiceTree\".\"id\" OR \"service_type_id_surplus\" = \"ServiceTree\".\"id\" ) ))"]} at (eval 2343)[/home/kes/perl5/perlbrew/perls/perl-5.24.1/lib/site_perl/5.24.1/DB/Commands.pm:971] line 3
After this error I have tried to add an 'alias':
my $partial = $c->model( 'ServicePackageSet' )->search([
{ service_type_id_covered => { -ident => 'ServiceTree.id' } },
{ service_type_id_surplus => { -ident => 'ServiceTree.id' } },
],{ select => \1, alias => 'partial' });
This change nothing.
After googling a bit I have found: https://www.perlmonks.org/?node_id=882510
and change my resulting query as:
my $pricelist = $c->model( 'ServiceTree' )->search({
},{
prefetch => [qw/ Price Package /],
'+select' => { exists => $partial->as_query },
'+as' => [ 'abc' ], ## <<<<<<<< HERE
order_by => [qw/ Package.short_name name /],
});
The error message should be improved to be meaningful. It should explicitly say: maybe you should use `+as`....