[Bast-commits] r3589 - in trunk/DBIx-Class: . lib/DBIx/Class t
matthewt at dev.catalyst.perl.org
matthewt at dev.catalyst.perl.org
Wed Jul 18 00:07:07 GMT 2007
Author: matthewt
Date: 2007-07-18 00:07:06 +0100 (Wed, 18 Jul 2007)
New Revision: 3589
Modified:
trunk/DBIx-Class/Changes
trunk/DBIx-Class/lib/DBIx/Class/ResultSet.pm
trunk/DBIx-Class/t/76joins.t
Log:
fix for count after slice (report and tests from JOHANL)
Modified: trunk/DBIx-Class/Changes
===================================================================
--- trunk/DBIx-Class/Changes 2007-07-17 13:22:31 UTC (rev 3588)
+++ trunk/DBIx-Class/Changes 2007-07-17 23:07:06 UTC (rev 3589)
@@ -1,5 +1,7 @@
Revision history for DBIx::Class
+ - count no longer returns negative values after slice
+ (report and test from JOHANL)
- rebless before building datetime_parser
(patch from mattlaw / Matt Lawrence)
Modified: trunk/DBIx-Class/lib/DBIx/Class/ResultSet.pm
===================================================================
--- trunk/DBIx-Class/lib/DBIx/Class/ResultSet.pm 2007-07-17 13:22:31 UTC (rev 3588)
+++ trunk/DBIx-Class/lib/DBIx/Class/ResultSet.pm 2007-07-17 23:07:06 UTC (rev 3589)
@@ -938,6 +938,7 @@
$count -= $self->{_attrs}{offset} if $self->{_attrs}{offset};
$count = $self->{attrs}{rows} if
$self->{attrs}{rows} and $self->{attrs}{rows} < $count;
+ $count = 0 if ($count < 0);
return $count;
}
Modified: trunk/DBIx-Class/t/76joins.t
===================================================================
--- trunk/DBIx-Class/t/76joins.t 2007-07-17 13:22:31 UTC (rev 3588)
+++ trunk/DBIx-Class/t/76joins.t 2007-07-17 23:07:06 UTC (rev 3589)
@@ -16,7 +16,7 @@
eval "use DBD::SQLite";
plan $@
? ( skip_all => 'needs DBD::SQLite for testing' )
- : ( tests => 63 );
+ : ( tests => 64 );
}
# figure out if we've got a version of sqlite that is older than 3.2.6, in
@@ -146,6 +146,9 @@
);
cmp_ok( scalar $rs->all, '==', scalar $rs->slice(0, $rs->count - 1), 'slice() with join has same count as all()' );
+ok(!$rs->slice($rs->count+1000, $rs->count+1002)->count,
+ 'Slicing beyond end of rs returns a zero count');
+
$rs = $schema->resultset("Artist")->search(
{ 'liner_notes.notes' => 'Kill Yourself!' },
{ join => { 'cds' => 'liner_notes' } });
More information about the Bast-commits
mailing list