Opened 12 years ago
Closed 12 years ago
#20463 closed Bug (fixed)
.get_or_create() leaves Postgres in 'current transaction is aborted...' state if da DataError occurs in create
| Reported by: | Ulrich Petri | Owned by: | nobody |
|---|---|---|---|
| Component: | Database layer (models, ORM) | Version: | 1.4 |
| Severity: | Release blocker | Keywords: | |
| Cc: | Triage Stage: | Accepted | |
| Has patch: | no | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
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.
Attachments (1)
Change History (5)
by , 12 years ago
| Attachment: | get_or_create_pgsql-test.diff added |
|---|
comment:1 by , 12 years ago
| Triage Stage: | Unreviewed → Accepted |
|---|
comment:2 by , 12 years ago
| Severity: | Normal → Release blocker |
|---|
comment:3 by , 12 years ago
UloPe: there's no reason why this test should be specific to PostgreSQL, this behavior should be guaranteed on all databases.
Russell: I'm not convinced it's a regression, but it's obviously a bug and it's fast to fix it, so I haven't investigated further!
comment:4 by , 12 years ago
| Resolution: | → fixed |
|---|---|
| Status: | new → closed |
Marking as a release blocker because it relates to some refactoring introduced in [59a35208]