Apparently I can add a negative number in an update expression but I cannot
subtract a positive number.
Snippet:
delta = new_allocation - record.quantity_allocated
db(db.production_jobs.id==record.production_job_id).update(
quantity_on_hand=db.production_jobs.quantity_on_hand - delta #
subtraction. DAL will not like it
)
Snippet raises this exception:
File
"/home/cjk/pybin/w-2-4-2/web2py/applications/Inventory/controllers/customer_order_product_lots.py",
line 70, in update_lot_record
quantity_on_hand=db.production_jobs.quantity_on_hand - delta
File "/home/cjk/pybin/w-2-4-2/web2py/gluon/dal.py", line 8820, in __sub__
raise SyntaxError("subtraction operation not supported for type")
SyntaxError: subtraction operation not supported for type
Hackish workaround:
delta = -(new_allocation - record.quantity_allocated) # flip value to negative
db(db.production_jobs.id==record.production_job_id).update(
quantity_on_hand=db.production_jobs.quantity_on_hand + delta # add
negative number. DAL okay with this
)
Is this the expected behavior?
Or am I missing something?
--
---
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 [email protected].
For more options, visit https://groups.google.com/groups/opt_out.