Changes between Initial Version and Version 2 of Ticket #35575
- Timestamp:
- Jul 3, 2024, 6:30:45 AM (6 months ago)
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()`. 2 2 3 3 Instead, 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: … … 7 7 An `IntegrityError` is correctly raised when calling `Model.save()` if any constraints involving `GeneratedField`s are violated. 8 8 9 Instead, the `GeneratedField`s should have their values recalculated as part of `Model.full_clean()`.9 Instead, the recalculated values for `GeneratedField`s should be used when checking constraints. 10 10 11 11 This ticket was raised after fixing the bug in #35560 with PR [https://github.com/django/django/pull/18309].