[Dbix-class] Second join gets eaten in _merge_attr
Matt S Trout
dbix-class at trout.me.uk
Wed Oct 31 02:07:49 GMT 2007
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?
--
Matt S Trout Need help with your Catalyst or DBIx::Class project?
Technical Director http://www.shadowcat.co.uk/catalyst/
Shadowcat Systems Ltd. Want a managed development or deployment platform?
http://chainsawblues.vox.com/ http://www.shadowcat.co.uk/servers/
More information about the DBIx-Class
mailing list