Works for me:
>>> db.define_table('tag_count',
... Field('name'),
... Field('count', 'integer'),
... format='%(title)s')
<Table tag_count (id,name,count)>
>>>
>>> import random
>>> for k in range(10):
... db.tag_count.insert(name='xxx',count=random.randint(0,20))
>>> print db(db.tag_count.name=='xxx').select(db.tag_count.name,
db.tag_count.count, orderby=~ db.tag_count.count, limitby=(0, 10))
tag_count.name,tag_count.count
xxx,17
xxx,17
xxx,16
xxx,10
xxx,9
xxx,9
xxx,8
xxx,7
xxx,1
xxx,0
I suspect your values are stored as strings. Perhaps you stored them as
strings and then you changed the type to "string". SQLite cannot handle
this kind of migrations.
On Saturday, February 16, 2013 5:59:34 PM UTC-6, Neil Johnson wrote:
>
> Hello
>
> I have a query like so
> result = db(db.tag_count.user_id == user_id).select(db.tag_count.name,
> db.tag_count.count, orderby=~ db.tag_count.count, limitby=(0, 10))
>
> where db.tag_count is defined as
>
> db.define_table('tag_count',
> Field('name'),
> Field('user_id', db.auth_user),
> Field('count', 'integer'),
> format='%(title)s')
>
>
> Which aims to return the rows with the highest tag counts
>
> In reality it returns the tag_count based on alphabetical rather numerical
> order. A sample ordering might be 21, 2,12,1 i.e. 2 > 12 where I would want
> 21,12,2,1
>
> I am using web2py 2.3.2 and SQLite
>
> Any thoughts on what I'm doing wrong?
>
> Many thanks,
>
> Neil
>
>
--
---
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.