#35560 closed Bug (fixed)
Model.full_clean() errors with GeneratedField and UniqueConstraint or CheckConstraint
Reported by: | Mark Gensler | Owned by: | Mark Gensler |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | 5.0 |
Severity: | Release blocker | Keywords: | generatedfield uniqueconstraint checkconstraint |
Cc: | Mark Gensler, Mariusz Felisiak, Lily Foote, Paolo Melchiorre | Triage Stage: | Ready for checkin |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Calling full_clean()
on an unsaved model instance which has either a UniqueConstraint
or CheckConstraint
raises the error:
AttributeError: Cannot read a generated field from an unsaved model.
This is similar to #35127.
The PR which will be attached shortly contains 4 new failing tests:
model_fields.test_generatedfield.GeneratedFieldTests.test_full_clean_with_unique_constraint model_fields.test_generatedfield.GeneratedFieldTests.test_full_clean_with_check_constraint model_fields.test_generatedfield.VirtualGeneratedFieldTests.test_full_clean_with_unique_constraint model_fields.test_generatedfield.VirtualGeneratedFieldTests.test_full_clean_with_check_constraint
Change History (12)
comment:1 by , 5 months ago
Summary: | Model.full_clean() errors with when GeneratedField and UniqueConstraint or CheckConstraint are present → Model.full_clean() errors with GeneratedField and UniqueConstraint or CheckConstraint |
---|
comment:2 by , 5 months ago
Has patch: | set |
---|---|
Owner: | changed from | to
Status: | new → assigned |
comment:3 by , 5 months ago
Patch needs improvement: | set |
---|
comment:4 by , 5 months ago
Cc: | added |
---|---|
Severity: | Normal → Release blocker |
Triage Stage: | Unreviewed → Accepted |
Hello Mark Gensler, thank you for this ticket report! And big thanks for the prompt PR.
comment:5 by , 4 months ago
Patch needs improvement: | unset |
---|---|
Triage Stage: | Accepted → Ready for checkin |
Note:
See TracTickets
for help on using tickets.
I've assigned this to myself as I'm happy to work on it. Will leave the discussion to the PR.