[Bast-commits] r8100 - DBIx-Class/0.08/branches/mssql_limit_regression/t/search

ribasushi at dev.catalyst.perl.org ribasushi at dev.catalyst.perl.org
Sat Dec 12 23:07:01 GMT 2009


Author: ribasushi
Date: 2009-12-12 23:07:00 +0000 (Sat, 12 Dec 2009)
New Revision: 8100

Added:
   DBIx-Class/0.08/branches/mssql_limit_regression/t/search/related_strip_prefetch.t
Log:
Extra test to highlight search_related inefficiency

Added: DBIx-Class/0.08/branches/mssql_limit_regression/t/search/related_strip_prefetch.t
===================================================================
--- DBIx-Class/0.08/branches/mssql_limit_regression/t/search/related_strip_prefetch.t	                        (rev 0)
+++ DBIx-Class/0.08/branches/mssql_limit_regression/t/search/related_strip_prefetch.t	2009-12-12 23:07:00 UTC (rev 8100)
@@ -0,0 +1,34 @@
+use strict;
+use warnings;
+
+use Test::More;
+use Test::Exception;
+
+use lib qw(t/lib);
+use DBIC::SqlMakerTest;
+use DBICTest;
+
+my $schema = DBICTest->init_schema();
+
+my $rs = $schema->resultset('CD')->search (
+  { 'tracks.id' => { '!=', 666 }},
+  { join => 'artist', prefetch => 'tracks' }
+);
+
+my $rel_rs = $rs->search_related ('tags');
+
+is_same_sql_bind (
+  $rel_rs->as_query,
+  '(
+    SELECT tags.tagid, tags.cd, tags.tag 
+      FROM cd me
+      JOIN artist artist ON artist.artistid = me.artist
+      LEFT JOIN track tracks ON tracks.cd = me.cdid
+      LEFT JOIN tags tags ON tags.cd = me.cdid
+    WHERE ( tracks.id != ? )
+  )',
+  [ [ 'tracks.id' => 666 ] ],
+  'Prefetch spec successfully stripped on search_related'
+);
+
+done_testing;




More information about the Bast-commits mailing list