yes, you are right, my bad, my old code have a race condition because of 
assigned with max id
*e.g.*
*have a race condition (don't use it if transaction is high)*
id_max = db.order.id.max()
maxID = db(db.order).select(id_max).first()[id_max]
order_id = int(maxID) + 1 if maxID else 1
db.item.order_id.default = order_id

*doesn't have a race condition (best practice)*
order_id_1 = db.order.insert(name = 'order1')
db.item.insert(name = 'item1', order_id = order_id_1)

best regards,
stifan

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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/d/optout.

Reply via email to