that's basic versioning theory of databases. 
If you do two operations in two separate transactions that, in "english" 
can be translated as "if you don't find this record, please insert it", the 
two will happily succeed one after another if they are concurrent. 
That's why unique constraints are a builtin feature that every backend has.

On Tuesday, August 12, 2014 10:24:48 PM UTC+2, Jack Kuan wrote:
>
> Hi,
>
> When using  update_or_insert(), say for example:  
> db.mytable.update_or_insert(q, name='test')
>
> Let's say the query, q, results in not finding any row in mytable, is it 
> possible that in another transaction in another request that when the same 
> update_or_insert(...) is called that it also doesn't find any row and thus 
> at the end, the two transcations both try to commit an insert, which could 
> result in duplicated rows(with different id's) or an integrity error(eg, if 
> there's an unique constraint)? Or is web2py smart enough to generate an 
> insert that is safe?
>
> Thanks
> Jack
>

-- 
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