[Bast-commits] r9475 - in DBIx-Class/0.08/trunk: lib/DBIx/Class lib/DBIx/Class/Storage t

ribasushi at dev.catalyst.perl.org ribasushi at dev.catalyst.perl.org
Mon May 31 15:13:28 GMT 2010


Author: ribasushi
Date: 2010-05-31 16:13:28 +0100 (Mon, 31 May 2010)
New Revision: 9475

Modified:
   DBIx-Class/0.08/trunk/lib/DBIx/Class/SQLAHacks.pm
   DBIx-Class/0.08/trunk/lib/DBIx/Class/Storage/DBI.pm
   DBIx-Class/0.08/trunk/t/746mssql.t
Log:
Fix Top-limit problem of missed bindvars

Modified: DBIx-Class/0.08/trunk/lib/DBIx/Class/SQLAHacks.pm
===================================================================
--- DBIx-Class/0.08/trunk/lib/DBIx/Class/SQLAHacks.pm	2010-05-31 15:11:51 UTC (rev 9474)
+++ DBIx-Class/0.08/trunk/lib/DBIx/Class/SQLAHacks.pm	2010-05-31 15:13:28 UTC (rev 9475)
@@ -340,6 +340,12 @@
 
       $mid_sel .= ', ' . $extra_order_sel->{$extra_col};
     }
+
+    # since whatever order bindvals there are, they will be realiased
+    # and need to show up in front of the entire initial inner subquery
+    # Unshift *from_bind* to make this happen (horrible, horrible, but
+    # we don't have another mechanism yet)
+    unshift @{$self->{from_bind}}, @{$self->{order_bind}};
   }
 
   # and this is order re-alias magic

Modified: DBIx-Class/0.08/trunk/lib/DBIx/Class/Storage/DBI.pm
===================================================================
--- DBIx-Class/0.08/trunk/lib/DBIx/Class/Storage/DBI.pm	2010-05-31 15:11:51 UTC (rev 9474)
+++ DBIx-Class/0.08/trunk/lib/DBIx/Class/Storage/DBI.pm	2010-05-31 15:13:28 UTC (rev 9475)
@@ -1466,7 +1466,9 @@
 
   # Can this fail without throwing an exception anyways???
   my $rv = $sth->execute();
-  $self->throw_exception($sth->errstr) if !$rv;
+  $self->throw_exception(
+    $sth->errstr || $sth->err || 'Unknown error: execute() returned false, but error flags were not set...'
+  ) if !$rv;
 
   $self->_query_end( $sql, @$bind );
 

Modified: DBIx-Class/0.08/trunk/t/746mssql.t
===================================================================
--- DBIx-Class/0.08/trunk/t/746mssql.t	2010-05-31 15:11:51 UTC (rev 9474)
+++ DBIx-Class/0.08/trunk/t/746mssql.t	2010-05-31 15:13:28 UTC (rev 9475)
@@ -301,6 +301,7 @@
       is ($limited_rs->count_rs->next, 6, "$test_type: Correct count_rs of limited right-sorted joined resultset");
 
       my $queries;
+      my $orig_debug = $schema->storage->debug;
       $schema->storage->debugcb(sub { $queries++; });
       $schema->storage->debug(1);
 
@@ -312,7 +313,7 @@
       is ($queries, 1, "$test_type: Only one query with prefetch");
 
       $schema->storage->debugcb(undef);
-      $schema->storage->debug(0);
+      $schema->storage->debug($orig_debug);
 
       is_deeply (
         [map { $_->name } ($limited_rs->search_related ('owner')->all) ],
@@ -338,7 +339,10 @@
     my ($sql, @bind) = @${$owners->page(3)->as_query};
     is_deeply (
       \@bind,
-      [ ([ 'me.name' => 'somebogusstring' ], [ test => 'xxx' ]) x 2 ],  # double because of the prefetch subq
+      [
+        $dialect eq 'Top' ? [ test => 'xxx' ] : (),                 # the extra re-order bind
+        ([ 'me.name' => 'somebogusstring' ], [ test => 'xxx' ]) x 2 # double because of the prefetch subq
+      ],
     );
 
     is ($owners->page(1)->all, 3, "$test_type: has_many prefetch returns correct number of rows");




More information about the Bast-commits mailing list