I guess my code is  more messed up than I thought. I'll try and clarify 
your points:

*What am I trying to achieve?*

In the db there are people (given by the auth_user table). From those 
people there are ones who are hierarchically above them and supervise 
them.They are called Supervisors. All people have mobile and phone 
extensions(numbers) . As far as my query goes, I'm getting the Supervisor' 
numbers and the people's numbers associated with the Supervisor. What I'm 
trying to accomplish: returning only the Supervisor' numbers.

*Would it make more sense to have it like this?*

I'm curious,why would a second table(extension_member) be needed?I think I 
will also need the extension_number in the 'extension' table since that 
table stores all the phone and mobile extensions.

*Why would you check the first name and last name when you already compared 
the ID with person?*

Now I am the one a bit confused. The comparison between the ID and the 
person was to connect both tables and then I would filter by the user I 
wanted. But now I'm not sure If I've been doing this correctly...? 

*Why would you use "like" for an integer field?*

It's the only way I know to check if a number begins as 9 or ~9 . Is there 
a simpler/optimised way?Also, as an aside, is there a way to use regular 
expressions in queries?

Thank you for all the help!

quarta-feira, 16 de Setembro de 2015 às 15:18:31 UTC+1, Leonel Câmara 
escreveu:
>
> This is the answer to the first problem:
>
> db.auth_user.Supervisor.requires=IS_EMPTY_OR(IS_IN_DB(db,'auth_user.id',
> db.auth_user._format))
>
> You can just remove it as it will use the format for auth_user anyway as 
> that's the default. So it becomes only:
>
> db.auth_user.Supervisor.requires=IS_EMPTY_OR(IS_IN_DB(db,'auth_user.id')
>
> As for the Extensions I'm very confused with what you're trying to achieve 
> and your table structure doesn't seem very good. Would it make more sense 
> to have it like this?
>
> db.define_table('extension',,
>                 Field('Supervisor' , 'reference 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))
>
> db.define_table('extension_member',
>             Field('extension' , 'reference extension'),
>             Field('member' , 'reference auth_user'),
>     
>
> I ask this because your query is utterly confusing, why would you check 
> the first name and last name when you already compared the ID with person, 
> why would you use "like" for an integer field. So many questions.
>
> In your questions you need to tells us *what* you're trying to achieve 
> not just *how*.
>

-- 
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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to