[Dbix-class] Prefetch and join on different tables
Nigel Metheringham
nigel at dotdot.it
Mon Jan 21 20:30:04 GMT 2013
Paula wrote:
> If the search is:
> my $rs1 = $c->model('weight::Mdata')->search($where,$attr,{prefetch =>
> 'mc'},{join =>'mt'});
> The DBIC TRACE shows that the join occurs between mdata and mt, and I
> get the following error:
> [error] DBIx::Class::ResultSet::next(): DBI Exception: DBD::mysql::st
> execute failed: Unknown column 'mc.h1' in 'where clause'
>
> Inversely, if the search is:
> my $rs1 = $c->model('weight::Mdata')->search($where,$attr,{join
> =>'mt'},{prefetch => 'mc'});
> The DBIC TRACE shows that the join (and the prefetch) occurs between
> mdata and mc, and I get the following error:
> [error] DBIx::Class::ResultSet::next(): DBI Exception: DBD::mysql::st
> execute failed: Unknown column 'mt.n_C' in 'where clause'
There should be a single attributes hash, so
my $rs1 = $c->model('weight::Mdata')
->search($where,
{ %{$attr},
prefetch => 'mc',
join => 'mt' });
[so the other attributes, the prefetch and the join are all part of a
single hash and not 3 different parameters passed to search]
Nigel.
--
[ Nigel Metheringham ------------------------------ nigel at dotdot.it ]
[ Ellipsis Intangible Technologies ]
More information about the DBIx-Class
mailing list