Bugs item #1699518, was opened at 2007-04-13 00:34
Message generated for change (Comment added) made by phd
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=540672&aid=1699518&group_id=74338
Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: General
Group: SQLObject release (specify)
Status: Open
>Resolution: Later
Priority: 5
Private: No
Submitted By: kumar mcmillan (kumar303)
>Assigned to: Oleg Broytmann (phd)
Summary: select(limit=n) - limit keyword is not recognized
Initial Comment:
0.8.1 release
here is a failing test case :(
from sqlobject import *
def test():
c = connectionForURI('sqlite:/:memory:')
class Foo(SQLObject):
bar = 1
Foo.createTable(connection=c)
f = Foo(connection=c)
f = Foo(connection=c)
assert Foo.select(connection=c).count() == 2
assert Foo.select(connection=c, limit=1).count() == 1
if __name__ == '__main__':
test()
----------------------------------------------------------------------
>Comment By: Oleg Broytmann (phd)
Date: 2007-04-16 22:28
Message:
Logged In: YES
user_id=4799
Originator: NO
Yes, that's a long-standing bug in SelectResults. Meanwhile you can use
.select()[:1] or .select().limit(1).
----------------------------------------------------------------------
Comment By: kumar mcmillan (kumar303)
Date: 2007-04-16 21:07
Message:
Logged In: YES
user_id=540473
Originator: YES
sorry, bad example. The bug is not with count(), it is with sql
reproduction of the entire select. It is not including the limit=limit
part of the query. Here is a better test, still failing.
from sqlobject import *
def test():
c = connectionForURI('sqlite:/:memory:')
class Foo(SQLObject):
bar = StringCol()
Foo.createTable(connection=c)
f = Foo(bar='bar', connection=c)
f = Foo(bar='foo', connection=c)
rs = Foo.select(connection=c)
assert len(list(rs)) == 2
rs = Foo.select(connection=c, limit=1)
print rs
assert len(list(rs)) == 1
if __name__ == '__main__':
test()
print "OK"
File Added: test_sresults.py
----------------------------------------------------------------------
Comment By: Oleg Broytmann (phd)
Date: 2007-04-16 17:16
Message:
Logged In: YES
user_id=4799
Originator: NO
Using both COUNT() and LIMIT is meaningless. LIMIT limits the number of
rows returned by SELECT, but SELECT COUNT() returns exactly 1 (one) row, so
what are you limiting?
If you want to limit what SELECT * returns and later count it - use few
separate queries, or a complex query with subqueries.
----------------------------------------------------------------------
Comment By: kumar mcmillan (kumar303)
Date: 2007-04-13 00:38
Message:
Logged In: YES
user_id=540473
Originator: YES
tested in SQLObject-0.10dev_r2521-py2.4.egg ... still broken
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=540672&aid=1699518&group_id=74338
|