Skip Menu |

This queue is for tickets about the DBIx-SearchBuilder CPAN distribution.

Report information
The Basics
Id: 3839
Status: resolved
Priority: 0/
Queue: DBIx-SearchBuilder

People
Owner: Nobody in particular
Requestors: vlyon [...] uk.yahoo-inc.com
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 0.88
Fixed in: (no value)



Subject: Count() returns incorrect value after a new Limit()
In Count() ... # If we haven't actually got all objects loaded in memory, we # really just want to do a quick count from the database. if ( $self->{'must_redo_search'} ) { # If we haven't already asked the database for the row count, do that $self->_DoCount unless ( $self->{'raw_rows'} ); #Report back the raw # of rows in the database return ( $self->{'raw_rows'} ); } ** Problem: $self->{'must_redo_search'} is true, but the new search is not done when a count is requested! Thats because the old value is still in $self->{'raw_rows'}. ** Work around: Call _DoCount() manually which forces it to redo the search and update the row count properly. ** Fix: um, dunno, maybe just do a _DoCount() if $self->{'must_redo_search'} is true, even if $self->{'raw_rows'} is set. (take away the: unless ...)
Date: Mon, 22 Sep 2003 11:17:05 -0400
From: Jesse <jesse [...] fsck.com>
To: rspier [...] pobox.com
CC: bug-dbix-searchbuilder [...] rt.cpan.org
Subject: [fwd] [cpan #3839] Count() returns incorrect value after a new Limit() (from: bug-DBIx-SearchBuilder@rt.cpan.org)
RT-Send-Cc:
Robrt: iirc this was your SearchBuilder change, no? This message about DBIx-SearchBuilder was sent to you by guest <> via rt.cpan.org Full context and any attached attachments can be found at: <URL: https://rt.cpan.org/Ticket/Display.html?id=3839 > In Count() ... # If we haven't actually got all objects loaded in memory, we # really just want to do a quick count from the database. if ( $self->{'must_redo_search'} ) { # If we haven't already asked the database for the row count, do that $self->_DoCount unless ( $self->{'raw_rows'} ); #Report back the raw # of rows in the database return ( $self->{'raw_rows'} ); } ** Problem: $self->{'must_redo_search'} is true, but the new search is not done when a count is requested! Thats because the old value is still in $self->{'raw_rows'}. ** Work around: Call _DoCount() manually which forces it to redo the search and update the row count properly. ** Fix: um, dunno, maybe just do a _DoCount() if $self->{'must_redo_search'} is true, even if $self->{'raw_rows'} is set. (take away the: unless ...) Show quoted text
----- End forwarded message ----- -- jesse reed vincent -- root@eruditorum.org -- jesse@fsck.com 70EBAC90: 2A07 FC22 7DB4 42C1 9D71 0108 41A3 3FB3 70EB AC90 Any e-mail sent to the SLA will immediately become the intellectual property of the SLA and the author of said message will enter into a period of indentured servitude which will last for a period of time no less than seven years.
This happens only if you do a Count() then add a new Limit() and then do another Count The first Count() returns the correct value, but the second one returns the same value as the first even thought the new Limit has reduced the actual count.
Date: Mon, 22 Sep 2003 11:22:38 -0400
From: Jesse <jesse [...] fsck.com>
To: Guest via RT <bug-DBIx-SearchBuilder [...] rt.cpan.org>
Subject: Re: [cpan #3839] Count() returns incorrect value after a new Limit()
RT-Send-Cc:
Right. I definitely agree that it's a bug. Just getting an opinion on the way it was introduced before we fix it. The raw_rows thing, was, iirc a perf issue being fixed. I don't want to just blow that away. Jesse On Mon, Sep 22, 2003 at 11:20:30AM -0400, Guest via RT wrote: Show quoted text
> > This message about DBIx-SearchBuilder was sent to you by guest <> via rt.cpan.org > > Full context and any attached attachments can be found at: > <URL: https://rt.cpan.org/Ticket/Display.html?id=3839 > > > This happens only if you do a Count() then add a new Limit() and then do > another Count > > The first Count() returns the correct value, but the second one returns > the same value as the first even thought the new Limit has reduced the > actual count. >
-- jesse reed vincent -- root@eruditorum.org -- jesse@fsck.com 70EBAC90: 2A07 FC22 7DB4 42C1 9D71 0108 41A3 3FB3 70EB AC90 Emacs is a pretty good operating system, but Unix has a better editor.
Date: Tue, 23 Sep 2003 22:39:44 -0700
From: Robert Spier <rspier [...] pobox.com>
To: Jesse <jesse [...] fsck.com>
CC: bug-dbix-searchbuilder [...] rt.cpan.org
Subject: Re: [fwd] [cpan #3839] Count() returns incorrect value after a new Limit() (from: bug-DBIx-SearchBuilder@rt.cpan.org)
RT-Send-Cc:
Show quoted text
> Robrt: iirc this was your SearchBuilder change, no?
Nope. I don't think so. I think you touched it after I did. raw_rows was yours... I added count_all. The problem that was being fixed was that COUNT() wasn't being used in cases it should have been. I'm pretty sure CountAll is for the pagination thing. Or both. I'm really not sure anymore. The requestor said.. Show quoted text
>This happens only if you do a Count() then add a new Limit() and then >do another Count
This is definitely broken, The idea behind the broken code is to prevent a query... but it's definitely wrong. _DoCount doesn't clear {must_redo_search}, because it doesn't actually fill the datastructures. I think the proper fix is to: 1. whenever checking for q[ if $self->{'must_redo_search'}; ], also check for $self->{items} being empty. 2. _DoCount can then clear must_redo_search. But I'm pretty sure there are two or three less invasive changes. (Especially since I may have done some stupid things with must_redo_search elsewhere.)