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.

Reply via email to