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.
--
Ticket URL: <https://code.djangoproject.com/ticket/20463>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* needs_better_patch: => 0
* stage: Unreviewed => Accepted
* needs_tests: => 0
* needs_docs: => 0
--
Ticket URL: <https://code.djangoproject.com/ticket/20463#comment:1>
* severity: Normal => Release blocker
Comment:
Marking as a release blocker because it relates to some refactoring
introduced in [59a35208]
--
Ticket URL: <https://code.djangoproject.com/ticket/20463#comment:2>
Comment (by aaugustin):
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!
--
Ticket URL: <https://code.djangoproject.com/ticket/20463#comment:3>
* status: new => closed
* resolution: => fixed
Comment:
In [changeset:"0e51d8eb66121b2558a38c9f4e366df781046873"]:
{{{
#!CommitTicketReference repository=""
revision="0e51d8eb66121b2558a38c9f4e366df781046873"
Fixed #20463 -- Made get_or_create more robust.
When an exception other than IntegrityError was raised, get_or_create
could fail and leave the database connection in an unusable state.
Thanks UloPe for the report.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/20463#comment:4>