Changes between Version 1 and Version 2 of Ticket #35425


Ignore:
Timestamp:
May 3, 2024, 8:41:17 AM (8 months ago)
Author:
Jacob Walls
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #35425 – Description

    v1 v2  
    106106---
    107107
    108 But perhaps in another ticket, or on the forum, we could consider the question of whether we should drive at the solution discussed several times by the participants on those tickets (~"if only there were a way to determine whether a field's value came from a default..."). On the thread I suggest we could do that by [https://forum.djangoproject.com/t/save-behavior-when-updating-model-with-default-primary-keys/30778/8 adjusting] `._state.adding = False` to agree with the admonition in the docs to be prepared for explicitly-specified primary keys to be treated as updates (here, at [https://forum.djangoproject.com/t/save-behavior-when-updating-model-with-default-primary-keys/30778/8 "the one gotcha..."]).
     108But perhaps in another ticket, or on the forum, we could consider whether we should drive at the solution discussed several times by the participants on those tickets (~"if only there were a way to determine whether a field's value came from a default..."). On the thread I suggest we could do that by [https://forum.djangoproject.com/t/save-behavior-when-updating-model-with-default-primary-keys/30778/8 adjusting] `._state.adding = False` to agree with the [https://docs.djangoproject.com/en/5.0/ref/models/instances/#explicitly-specifying-auto-primary-key-admonition documentation] stating that when explicitly specifying primary keys, "Django will assume you’re changing the existing record rather than creating a new one."
    109109
    110110To paraphrase Carlton, who [https://github.com/django/django/pull/12209#pullrequestreview-331284409 suggested reverting] #29260, that change traded one user's ''desire'' to optimize out one query, which can already be had with `force_insert=True`, for another person's ''obligation'' to start using `force_update=True` (once we fix it), which we [https://docs.djangoproject.com/en/5.0/ref/models/instances/#forcing-an-insert-or-update discourage], or to avoid `save()` altogether in favor of the QuerySet API, which seems like a loss for feature parity / understandability.
Back to Top