I must have spent a good hour hammering at this before I got it right.

Maybe rephrase it a bit, but I think it's a good example...

Assume that you want all users returned, but want to outline specifically 
those belonging to group A or B (with the others having their group set to 
None) in one query.

Also assume that in your app, all users belong to only one group.

It can be done with the following:

left=db.auth_membership.on(db.auth_user.id==db.auth_membership.user_id),db.auth_group.on((db.auth_group.id==db.auth_membership.group_id)&db.auth_group.role.belongs(("Group
 
A","Group B"))) 
Users = db().select(db.auth_user.ALL, db.auth_group.ALL, left=left)

-- 



Reply via email to