#33579: Raise a specialized exception when Model.save(update_fields) does not
affect any rows
-------------------------------------+-------------------------------------
Reporter: Simon Charette | Owner: nobody
Type: New feature | Status: new
Component: Database layer | Version: 4.0
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Simon Charette):
I feel like a `django.db.models.Model.save` forced update failure has
little to do with PEP-249; it's an exception that occurs at the ORM layer
and not at the backend one.
> Not sure if we should raise a ProgrammingError or InterfaceError
I would argue that we should not subclass either of them as it will result
in the same effect as raising `DatabaseError` from a callers perspective
(no way to differentiate between a database level error and an ORM level
one without a `str(exc)` comparison).
The reason for proposing to subclass `DatabaseError` is solely for
backward compatibility purposes which I believed would make the proposed
change less controversial.
If it was do all over again I think we should have a dedicated
`NoopUpdate` (better name welcome) type like we do with `DoesNotExist` and
`MultipleObjectsReturned` but [https://bugs.python.org/issue12029 since
Python doesn't allow for virtual subclass overrides in except clauses]
there's no way to provide a deprecation path for `except DatabaseError`
clauses in the wild that might already be handling this case.
--
Ticket URL: <https://code.djangoproject.com/ticket/33579#comment:4>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/0107017f95038308-a86942eb-c11b-4616-97b2-6e8af3c4e078-000000%40eu-central-1.amazonses.com.