[Django] #35560: Model.full_clean() errors with when GeneratedField and UniqueConstraint or CheckConstraint are present

2 views
Skip to first unread message

Django

unread,
Jun 25, 2024, 9:55:39 AM (4 days ago) Jun 25
to django-...@googlegroups.com
#35560: Model.full_clean() errors with when GeneratedField and UniqueConstraint or
CheckConstraint are present
-------------------------------------+-------------------------------------
Reporter: Mark | Owner: nobody
Gensler |
Type: Bug | Status: new
Component: Database | Version: 5.0
layer (models, ORM) | Keywords: generatedfield
Severity: Normal | uniqueconstraint checkconstraint
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
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
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/35560>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
Reply all
Reply to author
Forward
0 new messages