[Dbix-class] Search_rs not returning newly created rows
Kenneth S Mclane
ksmclane at us.ibm.com
Tue Jun 19 20:57:09 GMT 2012
Len Jaffe <lenjaffe at jaffesystems.com> wrote on 06/19/2012 03:45:34 PM:
> From:
>
> Len Jaffe <lenjaffe at jaffesystems.com>
>
> To:
>
> "DBIx::Class user and developer list" <dbix-class at lists.scsys.co.uk>
>
> Date:
>
> 06/19/2012 03:49 PM
>
> Subject:
>
> Re: [Dbix-class] Search_rs not returning newly created rows
>
>
> On Tue, Jun 19, 2012 at 3:22 PM, Kenneth S Mclane <ksmclane at us.ibm.com>
wrote:
> 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 = 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.
>
> --
> lenjaffe at jaffesystems.com 614-404-4214
www.volunteerable.net
> Proprietor: http://www.theycomewithcheese.com/ - An Homage to Fromage
> Greenbar: Grubmaster: 2012-2009, Grub Asst: 2008, Trained: 2007.
>
Strangely, I found that without the prefetch I am getting all the data,
it's just that the columns are null as you said. It seems to do the left
outer join when left to it's own devices. I can still access the fields in
the related tables from my templates. I just added some template code to
compensate for the null fields.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/dbix-class/attachments/20120619/8cb719ee/attachment-0001.htm
More information about the DBIx-Class
mailing list