[Dbix-class] Search_rs not returning newly created rows

Len Jaffe lenjaffe at jaffesystems.com
Tue Jun 19 20:45:34 GMT 2012


On Tue, Jun 19, 2012 at 3:22 PM, Kenneth S Mclane <ksmclane at us.ibm.com>wrot=
e:

> Len Jaffe <lenjaffe at jaffesystems.com> 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 =3D bar.foo_id

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

select *
from foo
left outer join bar on foo.id =3D 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.

-- =

lenjaffe at jaffesystems.com   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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/dbix-class/attachments/20120619/425=
2a270/attachment.htm


More information about the DBIx-Class mailing list