#35638: validate_constraints() fails on models with fields using db_default
-------------------------------------+-------------------------------------
Reporter: David Sanders | Owner: (none)
Type: Bug | Status: new
Component: Database layer | Version: dev
(models, ORM) |
Severity: Release blocker | Resolution:
Keywords: db_default | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Simon Charette):
* severity: Normal => Release blocker
* stage: Unreviewed => Accepted
Comment:
Thank you for your report!
We should adjust `_get_field_value_map` to take into account `db_default`
(and possibly rename to `_get_field_expr_map`) so all constraints are
adjusted appropriately. I suspect that other constraints as well as the
`unique=True` and `unique_together` validations that `validate_unique`
provides are also affected e.g.
{{{#!python
class Foo(models.Model):
bar = models.CharField(unique=True, db_default="bar")
Foo.objects.create()
Foo().validate_unique() # No ValidationError raised but would result in
an integrity error on `save`
}}}
''I haven't tested the above but I don't see any special handling of
`db_default` in `validate_unique`''
Marking as ''release blocker'' as `db_default` was introduced in 5.0.
--
Ticket URL: <https://code.djangoproject.com/ticket/35638#comment:1>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/01070190fea93044-8eba451e-1889-4312-9f04-387e73ad3f3a-000000%40eu-central-1.amazonses.com.