[Dbix-class] Second join gets eaten in _merge_attr

brett gardner brett at clientcomm.com.au
Wed Oct 31 03:05:49 GMT 2007


Happy to help out. Point me in the right direction.

Matt S Trout wrote:
> On Tue, Oct 30, 2007 at 09:22:59AM +1100, brett gardner wrote:
>   
>> I don't think its as simple as that.
>>
>> I recently had to implement this behaviour and realised that in some 
>> cases you might need to rename the columns in the query. eg
>>
>> $rs->search({'foo.bar_id' => 2},{join=>'foo'});
>>
>> then later
>>
>> my $new_rs = $rs->search({'foo.bar_id' = 45},{join=>'foo'});
>>
>> which would result in the query
>>
>> SELECT ....
>> FROM tbl1 LEFT JOIN foo ON (...)
>> LEFT JOIN foo foo2 ON (...)
>> WHERE
>> foo.bar_id = 2 AND foo.bar_id = 45
>>
>> Which is incorrect. as the second search clause should be "foo2.bar_id = 
>> 45".
>>     
>
> It is. But it's also a completely different problem, and one that's much
> harder to solve - I hope to find a way to allow DBIC to instrospect on
> the query tree sufficiently to handle this case intelligently as part of
> our refactor of SQL::Abstract - interested in helping?
>
>   



More information about the DBIx-Class mailing list