On Tue, Jun 19, 2012 at 3:22 PM, Kenneth S Mclane <[email protected]>wrote:

> Len Jaffe <[email protected]> wrote on 06/19/2012 02:06:21 PM:
>
> > Can you share the relevant queries?
> >
> > It may be that you're using an inner join when you need and outer
> > join if you can;t create the related records before the re-query.
> >
>
> This is the code with the prefetch commented out.
>

We were right. The prefetch is generating INNER JOINS, using the old
grammar, rather than the JOIN grammer, so if you do not have the related
records, you will not get the "master" records.

select *
from foo, bar
where foo.id = bar.foo_id

will only return records where the join condition (foo.id = bar.foo_id) is
true.  But

select *
from foo
left outer join bar on foo.id = bar.foo_id

will return a row for every row of foo and will return the data from bar
where the join condition is true, and tuples full of NULLs where there is
not bar row that satisfies the join condition.

I'm going to punt here, and announce that implementing the outer join in
DBIX/SQLA is left as an exercise for the reader.

But try the two queries above (modified for your database) from a SQL
prompt and compare & contrast the results.

Len.
- depending on your database, you might need to select foo.*, bar.* rather
than just the generic *. in order to get the data from both tables.


Len.

-- 
[email protected]   614-404-4214             www.volunteerable.net
Proprietor: http://www.theycomewithcheese.com/ - An Homage to Fromage
Greenbar <http://www.greenbartraining.org/>: Grubmaster: 2012-2009, Grub
Asst: 2008, Trained: 2007.
_______________________________________________
List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
Searchable Archive: http://www.grokbase.com/group/[email protected]

Reply via email to