I have been thinking about this.
How can one tell if the resulting records are going to have fields
from multiple tables?.


On Jan 30, 12:01 am, Massimo Di Pierro <[email protected]>
wrote:
> Immagine you have the following (suggested by user Nik):
>
> db.define_table('person',Field('name'),format='%(name)s')
> db.define_table('company', Field('name'),format='%(name)s')
> db.define_table('member',Field('person',db.Person),
> Field('company',db.company))
>
> and a new table
>
> db.define_table('manager', Field('member',db.member))
>
> Now you may want to a validator for managers with names of possible
> people who are members of the company.
> You can do it in this way (allowed):
>
>    db.manager.member.requires=IS_IN_DB(db,'member.id',lambda row: '%
> (name)s' % db.person[row.person])
>
> It would be nice to be able to also use this alternative syntax (not
> yet allowed):
>
> db.manager.member.requires=IS_IN_DB(db(db.member.person==db.person.id),'member.id','%
> (person.name)s')
>
> This is not yet possible but would be better because it would use a
> join instead of one select per option. Want to larn web2py? Try
> understand the IS_IN_DB validator in gluon/validators.py and implement
> the proposed syntax above.

Reply via email to