[web2py] Doing a select in a Virtual Field

2011-08-15 Thread Tom Coetser
Hi All, I'm new to web2py and am trying to get my mind around how virtual fields work. Given the following table: db.define_table(trip, Field(date, date), Field(odo, integer) ) which represents a trip taken by car on a specific date and the

[web2py] Doing a select in a Virtual Field

2011-08-15 Thread pbreit
I think you might have to dereference r. Something like r[0].odo since queries return a set even if there's only one element.

Re: [web2py] Doing a select in a Virtual Field

2011-08-15 Thread Tom Coetser
On Monday 15 August 2011 19:47:09 pbreit wrote: I think you might have to dereference r. Something like r[0].odo since queries return a set even if there's only one element. From my tests, the .first() in the query: r = db(q).select(db.trip.odo, orderby=o, limitby=(0,1)).first() seems to

Re: [web2py] Doing a select in a Virtual Field

2011-08-15 Thread pbreit
Oh, yeah, that's right. Sorry about that. I suspect the problem could indeed be with a query in a virtual field but I don't know enough about it to say for sure. Another option might be to implement it as just a regular function.