While update()ing fields are translated to column names, so you don't have to fetch the record just to increment it.
>>>db.define_table('myupdates', Field('quantity', 'integer')) >>>db(db.myupdates.id == 1)._update(quantity=db.myupdates.quantity + 1) 'UPDATE myupda SET quantity=(myupda.quantity + 1) WHERE (myupda.id = 1);' That piece of code (updating the product) is correct. On Saturday, February 23, 2013 5:22:04 PM UTC+1, Anthony wrote: > > db(db.product.id==key).update(quantity=db.product.quantity - >> value) > > > Here you probably want: > > db(db.product.id==key).update(quantity=db.product(key).quantity -value > ) > > db.product.quantity is a Field object, but you want to get the value of > that field for the particular record, which is db.product(key).quantity. > > Anthony > -- --- 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/groups/opt_out.