Hello,

I'm currently tring to solve a problem regarding a table da references 
itself. The default auth_user table has an extra field called 'Supervisor' 
that references that same table, since Supervisor is an user(a 
specialization of it,to be more specific).I have the following parameters 
added on db.py:

auth.settings.extra_fields['auth_user']= [Field('Supervisor','reference 
auth_user')]
db.auth_user.Supervisor.requires=IS_EMPTY_OR(IS_IN_DB(db,'auth_user.id',db.auth_user._format))

I also have another table that stores the user' numbers like so:

db.define_table('Extension',
                Field('Person' ,db.auth_user, requires = 
 IS_IN_DB(db,'auth_user.id')),
                Field('Supervisor' ,db.auth_user, requires = 
IS_EMPTY_OR(IS_IN_DB(db,'auth_user.id','%(first_name)s %(last_name)s'))),
                Field('Extension_number','integer',required = True))

I've tried to query my db for the extension of a person which is a 
supervisor like this:

query = ((db.auth_user.id == db.Extension.Person) & 
(db.auth_user.first_name == fname) & (db.auth_user.last_name == lname) & 
(~(db.Extension.Extension.like('9%'))))

The problem is, all the extensions associated with the supervisor (both his 
and the people he is a supervisor) are returned. This is wrong, since I 
only want his extensions and not those from the people he is a supervisor. 
What I'm I possibly missing on my query to make this work?  I hope I have 
made any sense here.


-- 
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.

Reply via email to