iterbetter object is True even if it is empty when use sqlite3

Bug #179644 reported by realazy
2
Affects Status Importance Assigned to Milestone
web.py
Fix Released
Medium
Anand Chitipothu

Bug Description

when using sqlite3 as db, the iterbetter object, which is web.query returned, is True even if it is empty.

please fix this, I don't want to list(ib) all the time, many thanks!

Revision history for this message
Anand Chitipothu (anandology) wrote : Re: [Bug 179644] iterbetter object is True even if it is empty when use sqlite3

On Jan 1, 2008 12:12 PM, realazy <email address hidden> wrote:
> Public bug reported:
>
> when using sqlite3 as db, the iterbetter object, which is web.query
> returned, is True even if it is empty.

Unfortunately, sqlite doesn't provide the number of rows in resultset,
so it is impossible to find the length without converting it to list.

But, i guess, it is misleading to return True always. Probably it
should raise an exception, when it can not determine the length.

Aaron Swartz (aaronsw)
Changed in webpy:
assignee: nobody → anandology
importance: Undecided → Medium
milestone: none → 0.31
status: New → Confirmed
milestone: 0.31 → 0.35
Revision history for this message
Anand Chitipothu (anandology) wrote :
Changed in webpy:
status: Confirmed → Fix Committed
Changed in webpy:
milestone: 0.35 → 0.33
Revision history for this message
Emyr Thomas (emzo) wrote :

For SQLite, couldn't we at least allow people to check to see if an IterBetter instance is empty or not by doing something like this?
http://chimezie.posterous.com/lazy-test-and-consumption-of-generators

Revision history for this message
Anand Chitipothu (anandology) wrote : Re: [Bug 179644] Re: iterbetter object is True even if it is empty when use sqlite3

On Wed, Nov 4, 2009 at 5:01 PM, Emyr Thomas <email address hidden> wrote:
> For SQLite, couldn't we at least allow people to check to see if an IterBetter instance is empty or not by doing something like this?
> http://chimezie.posterous.com/lazy-test-and-consumption-of-generators

Thats a good idea. I haven't thought about it. We already use that
patten in application.py.

Revision history for this message
Anand Chitipothu (anandology) wrote :

On Wed, Nov 4, 2009 at 6:42 PM, Anand Chitipothu <email address hidden> wrote:
> On Wed, Nov 4, 2009 at 5:01 PM, Emyr Thomas <email address hidden> wrote:
>> For SQLite, couldn't we at least allow people to check to see if an IterBetter instance is empty or not by doing something like this?
>> http://chimezie.posterous.com/lazy-test-and-consumption-of-generators
>
> Thats a good idea. I haven't thought about it. We already use that
> patten in application.py.

Fixed. Can you try it out and let me know if it looks alright?

http://github.com/webpy/webpy/commit/fa655ca9c1adc2fa3140564cf4d075e2910f6667
http://github.com/webpy/webpy/commit/9e5e40492f6e141df977a93def73423702038bcd

Changed in webpy:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.