Dear Antony ,
>From your example :
query = ' OR '.join(str(db.product.id == i) for i in [list of ids])
result type(query) is a string , could you tell me how to correctly convert
it to the pydal.objects.Query / Set ?
I'm trying query = db(query) , and get a pydal.objects.Set , but can't use
it , query.select() rise errors
Thanks!
On Sunday, March 29, 2015 at 1:37:03 AM UTC+8, Anthony wrote:
>
> In this particular case, you should instead use .belongs():
>
> query = db.product.id.belongs([list of ids])
>
> It's an interesting problem, though. A somewhat hackish solution would be:
>
> query = ' OR '.join(str(db.product.id == i) for i in [list of ids])
>
> The problem is that OR and AND operators always wrap the operands in
> parentheses, even when not necessary. The result is the nesting you observe
> when using reduce() or appending in a loop. Perhaps there should be a way
> to suppress the parentheses when not needed.
>
> Anthony
>
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
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/d/optout.