[Bast-commits] r6941 - in DBIx-Class/0.08/trunk: . lib/DBIx/Class

ribasushi at dev.catalyst.perl.org ribasushi at dev.catalyst.perl.org
Thu Jul 2 11:38:49 GMT 2009


Author: ribasushi
Date: 2009-07-02 11:38:49 +0000 (Thu, 02 Jul 2009)
New Revision: 6941

Modified:
   DBIx-Class/0.08/trunk/Changes
   DBIx-Class/0.08/trunk/lib/DBIx/Class/ResultSet.pm
Log:
Solve more prefetch inflation crap

Modified: DBIx-Class/0.08/trunk/Changes
===================================================================
--- DBIx-Class/0.08/trunk/Changes	2009-07-02 11:38:31 UTC (rev 6940)
+++ DBIx-Class/0.08/trunk/Changes	2009-07-02 11:38:49 UTC (rev 6941)
@@ -6,8 +6,8 @@
         - New resultsed method count_rs, returns a ::ResultSetColumn
           which in turn returns a single count value
         - Even better support of count with limit
-        - Count on related left-joined empty resultsets now correctly
-          returns 0
+        - count/all on related left-joined empty resultsets now correctly
+          returns 0/()
         - Fixed regression when both page and offset are specified on
           a resultset
         - Fixed HRI returning too many empty results on multilevel

Modified: DBIx-Class/0.08/trunk/lib/DBIx/Class/ResultSet.pm
===================================================================
--- DBIx-Class/0.08/trunk/lib/DBIx/Class/ResultSet.pm	2009-07-02 11:38:31 UTC (rev 6940)
+++ DBIx-Class/0.08/trunk/lib/DBIx/Class/ResultSet.pm	2009-07-02 11:38:49 UTC (rev 6941)
@@ -957,7 +957,9 @@
 
 sub _construct_object {
   my ($self, @row) = @_;
-  my $info = $self->_collapse_result($self->{_attrs}{as}, \@row);
+
+  my $info = $self->_collapse_result($self->{_attrs}{as}, \@row)
+    or return ();
   my @new = $self->result_class->inflate_result($self->result_source, @$info);
   @new = $self->{_attrs}{record_filter}->(@new)
     if exists $self->{_attrs}{record_filter};
@@ -967,6 +969,14 @@
 sub _collapse_result {
   my ($self, $as_proto, $row) = @_;
 
+  # if the first row that ever came in is totally empty - this means we got
+  # hit by a smooth^Wempty left-joined resultset. Just noop in that case
+  # instead of producing a {}
+  #
+  # Note the double-defined - $row may be [ 0, '' ]
+  #
+  return undef unless ( defined List::Util::first { defined $_ } (@$row) );
+
   my @copy = @$row;
 
   # 'foo'         => [ undef, 'foo' ]
@@ -1227,7 +1237,7 @@
   $tmp_attrs->{select} = $rsrc->storage->_count_select ($rsrc, $tmp_attrs);
   $tmp_attrs->{as} = 'count';
 
-  # read the function comment
+  # read the comment on top of the actual function to see what this does
   $tmp_attrs->{from} = $self->_switch_to_inner_join_if_needed (
     $tmp_attrs->{from}, $tmp_attrs->{alias}
   );
@@ -1259,7 +1269,7 @@
 
   $sub_attrs->{select} = $rsrc->storage->_subq_count_select ($rsrc, $sub_attrs);
 
-  # read the function comment
+  # 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}
   );
@@ -1426,6 +1436,7 @@
   }
 
   $self->set_cache(\@obj) if $self->{attrs}{cache};
+
   return @obj;
 }
 
@@ -2024,7 +2035,7 @@
 #
 # used to determine if a subquery is neccessary
 #
-# supports some  virtual attributes:
+# supports some virtual attributes:
 #   -join
 #     This will scan for any joins being present on the resultset.
 #     It is not a mere key-search but a deep inspection of {from}




More information about the Bast-commits mailing list