book chapter 6.17.6 queries not understanding the binary operators results

1 view
Skip to first unread message

Johan

unread,
Sep 7, 2010, 3:00:51 PM9/7/10
to web2py-users
In book chapter 6.17.6 I expect different return in the following
example:

>>> rows = db((db.person.name=='Alex') & (db.person.id>3)).select()
>>> for row in rows: print row.id, row.name
4 Alex

Why does it return 4 Alex ? I expect none, as there is no record with
id>3 and name == Alex.

I also don't understand the last example:

>>> rows = db((db.person.name=='Alex') | (db.person.id>3)).select()
>>> for row in rows: print row.id, row.name
2 Bob
3 Carl

I expect it to return 1 Alex.


mdipierro

unread,
Sep 7, 2010, 3:24:20 PM9/7/10
to web2py-users
You are right. Cut and paste mess.

Massimo
Reply all
Reply to author
Forward
0 new messages