[Catalyst] has_many but no left join?!

Robert Wohlfarth rbwohlfarth at gmail.com
Tue Jun 18 18:09:20 GMT 2013


On Tue, Jun 18, 2013 at 12:58 PM, Stephen Shorrock <
stephen.shorrock at gmail.com> wrote:

> Thanks Robert.
>
> I've attempted to extract the relevant relationship from my code, though
> when i use it i intend to group by and test for a not exists via matching=
 a
> null row with the left join.  I really need to have a left join in this
> relationship. It appears to be working for other has_many relationships b=
ut
> not under these circumstances. I wondered whether any knew of any
> conditions that might prevent it from working.
>
> Ah, well then I answered the wrong question :)

How about this code?
$c->model('MyApp::IndexStatus')->search({'old_statuses.id' =3D>
undef},{join=3D>'old_statuses'})

>From my novice understanding of DBIx::Class, I would expect that to find
all records from MyApp::IndexStatus that do not have a corresponding row in
old_statuses. The "join" tells the SQL generator to join the tables so that
you can add conditions about old_statuses. DBIx::Class automatically does a
LEFT JOIN because the relationship is declared has_many.

-- =

Robert Wohlfarth
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/catalyst/attachments/20130618/29f65=
b54/attachment.htm


More information about the Catalyst mailing list