Test for restricted prefetch (now passing again after previous commit)
[dbsrgits/DBIx-Class.git] / t / prefetch / incomplete.t
index 5d4aee5..4cfbdfc 100644 (file)
@@ -10,7 +10,7 @@ my $schema = DBICTest->init_schema();
 
 lives_ok(sub {
   # while cds.* will be selected anyway (prefetch currently forces the result of _resolve_prefetch)
-  # only the requested me.name column will be fetched.
+  # only the requested me.name/me.artistid columns will be fetched.
 
   # reference sql with select => [...]
   #   SELECT me.name, cds.title, me.artistid, cds.cdid, cds.artist, cds.title, cds.year, cds.genreid, cds.single_track FROM ...
@@ -109,4 +109,19 @@ throws_ok(
   'Sensible error message on mis-specified "as"',
 );
 
+# check complex limiting prefetch without the join-able columns
+{
+  my $pref_rs = $schema->resultset('Owners')->search({}, {
+    rows => 3,
+    offset => 1,
+    columns => 'name',  # only the owner name, still prefetch all the books
+    prefetch => 'books',
+  });
+
+  lives_ok {
+    is ($pref_rs->all, 1, 'Expected count of objects on limtied prefetch')
+  } "Complex limited prefetch works with non-selected join condition";
+}
+
+
 done_testing;