I was browsing django's source and looked at get_or_create. Shouldn't it be wrapped with a transaction?
Thanks
Looking at this diff it looks like as of Revision 8315, that has been handle explicitly within the get_or_create()
method.
As @reshefm pointed out, this was properly solved in rev 8670 where force_insert=True
was added to obj.save()
to ensure that during a race condition, all instances will attempt an insert (and not fall back to update) so only one will succeed while others will fail. Failing instances will proceed to do another get()
.
In terms of release version, this fix was first introduce in release 1.0.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With