Does dbix::Class support nested selects now?


> -----Original Message-----
> From: Rob Kinyon [mailto:[email protected]]
> Sent: 01 March 2009 03:46
> To: DBIx::Class user and developer list
> Subject: [Dbix-class] Prefetch + rows
>
> All -
>
>     I think I have a solution to the TODO tests in
> t/98rows_prefetch.t and I think this may solve other issues, as well.
>
>     The problem: Non-data aspects to the query (such as rows)
> are affecting the pull of prefetch'ed data.
>
>     The solution: Put the main query in a subquery. So, if we had
>
>     $foo_rs->search({
>         col1 => 3
>     }, {
>         rows => 2
>         prefetch => 'bar',
>     });
>
>     That currently translates (in MySQL) to "SELECT me.*,
> bar.* FROM foo me JOIN bar USING (...) WHERE me.col1 = 3
> LIMIT 2". If there are 3 rows in bar to each row in foo, we
> still only get the first two rows.
> The query -should- be "SELECT me.*, bar.* FROM ( SELECT me.*
> FROM foo me WHERE col1 = 3 LIMIT 2 ) me JOIN bar USING
> (...)". That way, the limit is against the main query and the
> prefetch happens outside it.
> Thus, the right number of rows are pulled back.
>
>     I think that transformation will work for all prefetches
> and I'm working on applying that fix in the prefetch branch.
> Does anyone see anything wrong with that?
>
> Rob
>
> _______________________________________________
> 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]
>

--------------------------------------------------------------------------
NOTICE: If received in error, please destroy and notify sender. Sender does not 
intend to waive confidentiality or privilege. Use of this email is prohibited 
when received in error.

_______________________________________________
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