[Bast-commits] r6403 - in DBIx-Class/0.08/branches/top-crap: lib/DBIx/Class t

caelum at dev.catalyst.perl.org caelum at dev.catalyst.perl.org
Sun May 24 17:17:49 GMT 2009


Author: caelum
Date: 2009-05-24 17:17:49 +0000 (Sun, 24 May 2009)
New Revision: 6403

Modified:
   DBIx-Class/0.08/branches/top-crap/lib/DBIx/Class/SQLAHacks.pm
   DBIx-Class/0.08/branches/top-crap/t/42toplimit.t
Log:
fix (some) SQLA::Limit warnings for Top

Modified: DBIx-Class/0.08/branches/top-crap/lib/DBIx/Class/SQLAHacks.pm
===================================================================
--- DBIx-Class/0.08/branches/top-crap/lib/DBIx/Class/SQLAHacks.pm	2009-05-24 17:15:25 UTC (rev 6402)
+++ DBIx-Class/0.08/branches/top-crap/lib/DBIx/Class/SQLAHacks.pm	2009-05-24 17:17:49 UTC (rev 6403)
@@ -130,6 +130,11 @@
   @rest = (-1) unless defined $rest[0];
   croak "LIMIT 0 Does Not Compute" if $rest[0] == 0;
     # and anyway, SQL::Abstract::Limit will cause a barf if we don't first
+
+  if ($self->{limit_dialect} eq 'Top' && !defined($order)) {
+    $order = '1 ASC';
+  }
+
   my ($sql, @where_bind) = $self->SUPER::select(
     $table, $self->_recurse_fields($fields), $where, $order, @rest
   );

Modified: DBIx-Class/0.08/branches/top-crap/t/42toplimit.t
===================================================================
--- DBIx-Class/0.08/branches/top-crap/t/42toplimit.t	2009-05-24 17:15:25 UTC (rev 6402)
+++ DBIx-Class/0.08/branches/top-crap/t/42toplimit.t	2009-05-24 17:17:49 UTC (rev 6403)
@@ -51,8 +51,7 @@
   my $subquery = $sa->select( [{ subq => \['(SELECT * FROM foo)'] }], [qw{bar baz}], undef, undef, 1, 3);
   is_same_sql(
     $subquery,
-    "SELECT * FROM ( SELECT TOP 1 * FROM ( SELECT TOP 4 bar,baz FROM (SELECT * FROM foo) ) AS foo) AS bar",
-  );
+    "SELECT * FROM ( SELECT TOP 1 * FROM ( SELECT TOP 4 bar,baz FROM (SELECT * FROM foo) subq ORDER BY 1 ASC) AS foo ORDER BY 1 DESC) AS bar ORDER BY 1 ASC",);
 
   is (@w, 0, 'No warnings on limit with subquery')
     || diag join ("\n", @w);




More information about the Bast-commits mailing list