[Dbix-class] Bad/missing joins on generated SQL (0.08112)

Peter Rabbitson rabbit+dbic at rabbit.us
Tue Sep 29 19:25:18 GMT 2009


Nilson Santos Figueiredo Jr. wrote:
> So, it seems like I'm always prone to this kind of stuff.
> Well, anyway, today I moved some code from a server with DBIC 0.08107
> to a new server, with the latest DBIC 0.08112 and some joins stopped
> working.
> 
> Specifically, this query doesn't produce the desired results anymore:
> 
>   my $rs = $schema->resultset('FilingPDF')->search(
>       { 'me.file_path' => undef, processing => '0', ticker => { '!=', undef } },
>       {
>           prefetch => { filing => 'company' },
>           join     => { filing => { company => 'tickers' } },
>           group_by => 'me.id'
>       },
>   );
> 

Before going further qualify your joined column names. A very complex dance
takes place to make sure the correct joins are brought in, and unqualified
column names upset it. It was deemed a reasonable compromise, as if the
joins are wrongly omitted, the query will fail, instead of returning incorrect
results.

As to why the convoluted subquery is necessary - it allows an arbitrarily
complex group_by on the main table while preserving prefetches.

Cheers



More information about the DBIx-Class mailing list