#28577 closed New feature (fixed)
Create system checks for mutable defaults on ArrayField and JSONField
| Reported by: | Flávio Juvenal | Owned by: | Flávio Juvenal |
|---|---|---|---|
| Component: | Core (System checks) | Version: | dev |
| Severity: | Normal | Keywords: | check |
| Cc: | Triage Stage: | Accepted | |
| Has patch: | yes | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | yes |
| Easy pickings: | no | UI/UX: | no |
Description
Django docs state "Incorrectly using default=[] creates a mutable default that is shared between all instances of ArrayField." [1].
This is a subtle bug that can be prevented with a new system check. IMO error prevention is good UX. Django should have system checks for those warnings in docs.
I've implemented this check: https://github.com/django/django/pull/8930
[1] https://docs.djangoproject.com/en/1.11/ref/contrib/postgres/fields/#django.contrib.postgres.fields.ArrayField
Change History (11)
comment:1 by , 8 years ago
| Owner: | changed from to |
|---|---|
| Status: | new → assigned |
comment:2 by , 8 years ago
| UI/UX: | unset |
|---|
comment:3 by , 8 years ago
| Version: | 1.11 → master |
|---|
comment:4 by , 8 years ago
| Summary: | Create system check for ArrayField(default=[]) (ArrayField with non-callable mutable default) → Create system checks for mutable defaults on ArrayField and JSONField |
|---|
comment:5 by , 8 years ago
| Triage Stage: | Unreviewed → Ready for checkin |
|---|
comment:6 by , 8 years ago
| Patch needs improvement: | set |
|---|---|
| Triage Stage: | Ready for checkin → Accepted |
comment:7 by , 8 years ago
Note:
See TracTickets
for help on using tickets.
PR updated: https://github.com/django/django/pull/8930