[Dbix-class] Possible minor bug in result set pager. Test included.

Randy Moore ramoore at axion-it.com
Sun Sep 25 19:44:12 GMT 2011


I have run into a minor bug (or at least change in behavior) of the 
pager in a result set after upgrading to 0.08195.  I wish I could tell 
you what version I was running before the upgrade, but I don't 
remember.  It hadn't been upgraded for at least a year.

Basically,  adding both join and prefetch set to empty strings causes an 
error in the pager.  It seems ok for the resultset itself.   
Interestingly, it take both 'join' and 'prefetch' for this to happen.  
Either one alone is ok.

Setting them to 'undef' instead of an empty string works properly.

------ broken ------
my $it = $rs->search(
     { order_by => 'title',
       rows => 3,
       join => '',
       prefetch => '',
       page => 1 }

Here is a patch to the pager test file:

# diff -urN t/67pager.t2 t/67pager.t

--- t/67pager.t2        2011-09-25 15:17:49.000000000 -0400
+++ t/67pager.t 2011-09-25 15:17:37.000000000 -0400
@@ -22,6 +22,8 @@
      { order_by => 'title',
        rows => 3,
+      join => '',
+      prefetch => '',
        page => 1 }

And here is the output:

# perl -Ilib t/67pager.t
ok 1 - Initial count sanity check
ok 2 - No queries on rs/pager creation
ok 3 - Pager created with correct entries_per_page
ok 4 - Set nonexistent page
ok 5 - Page set behaves correctly
ok 6 - Set 2nd page
ok 7 - No queries on total_count-independent methods
DBIx::Class::ResultSet::__ANON__(): No such relationship  on CD at 
/usr/lib/perl5/site_perl/5.8.8/Class/Accessor/Chained/Fast.pm line 14
# Tests were run but no plan was declared and done_testing() was not seen.

The work around it easy now that I've found the problem.  But, this has 
change broken a lot of dynamically built search

Hopefully this will help if anyone else these strange 'No such 
relationship  on <tablename>' errors.  Notice that the relationship name 
is blank in there.


Randy Moore
Axion Information Technologies, Inc.

phone: 301-587-3300 x 511
fax:   301-445-3947


More information about the DBIx-Class mailing list