Changes between Initial Version and Version 2 of Ticket #35575


Ignore:
Timestamp:
Jul 3, 2024, 6:30:45 AM (6 months ago)
Author:
Mark Gensler
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #35575 – Description

    initial v2  
    1 `GeneratedField`s on a model instance are not recalculated during `Model.full_clean()`. Therefore, if a `GeneratedField` is included in the `*expressions` or `fields` parameters of a `UniqueConstraint` or `CheckConstraint` in the instance's `Model._meta`, the values of the `GeneratedField` attribute are not recalculated prior to calling `BaseConstraint.validate()`.
     1`GeneratedField`s on a model instance are not recalculated during `Model.full_clean()`. Therefore, if a `GeneratedField` is included in the `*expressions` or `fields` parameters of a `UniqueConstraint` or `CheckConstraint` in the instance's `Model._meta`, the new values of the `GeneratedField` attribute are not uaed by `BaseConstraint.validate()`.
    22
    33Instead, the model instance's `GeneratedField` attribute will return the value which corresponds to the most recent refresh of the instance from the database. If the instance is new and has not yet been saved, the following error is raised:
     
    77An `IntegrityError` is correctly raised when calling `Model.save()` if any constraints involving `GeneratedField`s are violated.
    88
    9 Instead, the `GeneratedField`s should have their values recalculated as part of `Model.full_clean()`.
     9Instead, the recalculated values for `GeneratedField`s should be used when checking constraints.
    1010
    1111This ticket was raised after fixing the bug in #35560 with PR [https://github.com/django/django/pull/18309].
Back to Top