You are absolutely correct. While testing I used sqlitebrowser to insert records, and it inserted strings instead of integers.
Thank you very much, Sheldon On Apr 13, 10:01 pm, mdipierro <[email protected]> wrote: > I do not understand. > > This should be correct > > auth_membership.user_id=4 > > This should not be correct > > auth_membership.user_id='4' > > because auth_membership.user_id is a of type 'reference' and therefore > contains an integer. If you are using SQLite it is possible that > auth_membership.user_id contains a string if you forced it in there > (like you user executesql to do the insert) because SQLite does not > enforce types. > > I think the problem is not wrong query but wrong data in db. > > Is it possible that you did a manual insert of you set used a custom > membership table? > > Massimo > > On Apr 13, 11:43 pm, Sheldon <[email protected]> wrote: > > > > > Newbie DAL question > > > I'm new to web2py and I'm trying to get the following code to > > work, but it didn't return any results when there should have > > been two rows. > > > user_id = '4' > > rows = db( > > (db.auth_membership.user_id==user_id) & > > (db.auth_membership.group_id==db.auth_group.id) & > > (db.auth_membership.user_id==db.auth_user.id) > > ).select( db.auth_group.role, db.auth_user.first_name, > > db.auth_user.id) > > > So I tried the raw SQL that _select() generates: > > > SELECT auth_group.role, auth_user.first_name, auth_user.id > > FROM auth_user, auth_group, auth_membership > > WHERE ((auth_membership.user_id=4 > > AND auth_membership.group_id=auth_group.id) > > AND auth_membership.user_id=auth_user.id); > > > Which didn't work until I put quotes around the 4 (user_id) > > which then worked as its supposed to: > > > SELECT auth_group.role, auth_user.first_name, auth_user.id > > FROM auth_user, auth_group, auth_membership > > WHERE ((auth_membership.user_id='4' > > AND auth_membership.group_id=auth_group.id) > > AND auth_membership.user_id=auth_user.id); > > > How can I force the DAL to generate quotes when a string is > > passed to the db()? Is this something that is taken care of > > in the model? If so, since this is an Auth table, how can I > > change it? > > > Thanks, > > Sheldon -- To unsubscribe, reply using "remove me" as the subject.

