On 10/28/2010 1:54 AM, Andrew Thompson wrote:
I'm trying to get around the problem of not being able to do a join in
the IS_IN_DB(). I've got the following, which I thought was working
until I realized that it's using the id field from both tables. Can I
alias a field from mol as id? (I don't need the actual id field from
mol in this instance.)
allplaced = db(db.mol.removed==None).select()
Field('machine',db.machine,
requires=IS_IN_DB(db(~db.machine.id.belongs(allplaced)),
db.machine.id, '%(tag)s')),
Open to suggestions of a better way to do this.
I found that you can alias tables, but I couldn't make it alias the
field as well, unless I just wasn't doing it wrong.
I went with this, generating a real list instead of passing along a
resultset:
allplaced = [x.machine for x in db(db.mol.removed==None).select()]
Oh, and i'm using SQLFORM.factory, so web2py isn't trying to figure out
this magic each time.
--
Andrew Thompson
http://aktzero.com/