.get_or_create() leaves Postgres in 'current transaction is aborted...' state if da DataError occurs in create
|Reported by:||UloPe||Owned by:||nobody|
|Component:||Database layer (models, ORM)||Version:||1.4|
|Has patch:||no||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
Calling .get_or_create() with invalid data (e.g. broken UTF-8) in any of the fields in the 'default' argument causes a DataError (previously DatabaseError) to be thrown.
On Postgres this leads to the current transaction being left in the "InternalError: current transaction is aborted, commands ignored until end of transaction block" state.
The reason for this is that .get_or_create() creates a savepoint but only rolls it back on IntegrityError, which DataError is not a subclass of.
I'll attach a diff with a test for this behaviour.
Change History (5)
Changed 2 years ago by UloPe
comment:1 Changed 2 years ago by claudep
- Needs documentation unset
- Needs tests unset
- Patch needs improvement unset
- Triage Stage changed from Unreviewed to Accepted