From: Peter Rabbitson Date: Thu, 2 Jul 2009 22:24:00 +0000 (+0000) Subject: Merge 'trunk' into 'mssql_top_fixes' X-Git-Tag: v0.08108~12^2~8 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=1e1ce814212b6f20cd7e16f17249d33dd7502692;p=dbsrgits%2FDBIx-Class.git Merge 'trunk' into 'mssql_top_fixes' r6932@Thesaurus (orig r6931): ribasushi | 2009-07-02 08:08:33 +0200 Another candidate for somethingawful.com (fix left join-ed count) r6934@Thesaurus (orig r6933): ribasushi | 2009-07-02 09:04:13 +0200 Changelog r6935@Thesaurus (orig r6934): ribasushi | 2009-07-02 11:23:48 +0200 cleanup r6936@Thesaurus (orig r6935): ijw | 2009-07-02 12:41:01 +0200 Check fetched rows == count for related resultsets r6937@Thesaurus (orig r6936): ijw | 2009-07-02 12:43:47 +0200 Confirm prefetch doesn't affect main row fetch, and main row fetch works with and without counting r6938@Thesaurus (orig r6937): ribasushi | 2009-07-02 12:52:51 +0200 More fail (fix is known but needs work) r6939@Thesaurus (orig r6938): ribasushi | 2009-07-02 13:07:22 +0200 And more fail r6940@Thesaurus (orig r6939): ribasushi | 2009-07-02 13:16:46 +0200 These tests are in prefetch/count.t r6941@Thesaurus (orig r6940): ribasushi | 2009-07-02 13:38:31 +0200 cleanup r6942@Thesaurus (orig r6941): ribasushi | 2009-07-02 13:38:49 +0200 Solve more prefetch inflation crap r6943@Thesaurus (orig r6942): ribasushi | 2009-07-02 13:47:41 +0200 Make the code readable r6944@Thesaurus (orig r6943): ribasushi | 2009-07-02 15:52:35 +0200 Everything works, just need to fix join-path chaining over search_related (to guard against obscure db quirks) r6946@Thesaurus (orig r6945): caelum | 2009-07-02 21:06:32 +0200 add sybase reconnect test r6948@Thesaurus (orig r6947): ribasushi | 2009-07-02 22:20:21 +0200 Last part of the join handling puzzle r6951@Thesaurus (orig r6950): ribasushi | 2009-07-03 00:14:50 +0200 r6360@Thesaurus (orig r6359): arcanez | 2009-05-21 20:18:52 +0200 branch to work on prefetch/select r6361@Thesaurus (orig r6360): arcanez | 2009-05-21 20:32:46 +0200 failing test r6373@Thesaurus (orig r6372): ribasushi | 2009-05-22 11:07:26 +0200 Simplify unresolvable test by arcanez r6905@Thesaurus (orig r6904): ribasushi | 2009-07-01 12:54:03 +0200 Extend test r6950@Thesaurus (orig r6949): ribasushi | 2009-07-03 00:14:09 +0200 Apparent fix - simply delay the in_storage flagging of the main object until all prefetched objects are inflated. The rest of the changes are just cosmetics, preparing for the collapse_result rewrite r6953@Thesaurus (orig r6952): ribasushi | 2009-07-03 00:17:22 +0200 Changes --- 1e1ce814212b6f20cd7e16f17249d33dd7502692 diff --cc lib/DBIx/Class/ResultSet.pm index 3ebb162,58ccaa3..32f6b5a --- a/lib/DBIx/Class/ResultSet.pm +++ b/lib/DBIx/Class/ResultSet.pm @@@ -1254,14 -1274,13 +1274,20 @@@ sub _count_subq_rs $sub_attrs->{select} = $rsrc->storage->_subq_count_select ($rsrc, $sub_attrs); + # read the comment on top of the actual function to see what this does + $sub_attrs->{from} = $self->_switch_to_inner_join_if_needed ( + $sub_attrs->{from}, $sub_attrs->{alias} + ); + + # this is so that ordering can be thrown away in things like Top limit + $sub_attrs->{-for_count_only} = 1; + + my $sub_rs = $rsrc->resultset_class->new ($rsrc, $sub_attrs); ++ $attrs->{from} = [{ - count_subq => $rsrc->resultset_class->new ($rsrc, $sub_attrs )->as_query + -alias => 'count_subq', + -source_handle => $rsrc->handle, + count_subq => $sub_rs->as_query, }]; # the subquery replaces this