Opened 3 days ago
Last modified 3 days ago
#36262 assigned Cleanup/optimization
GeneratedField.db_persist defaults to None but is required to be set as either True or False
Description (last modified by ) ¶
Description:
GeneratedField.db_persist
attribute is set to db_persist=None
, which implies that the value can be None
. However, just 4 lines lower in the code, it is required to be either True
or False
. This inconsistency leads a developer to believe that it can be left blank but it cannot.
Steps to Reproduce:
- Create a model using
GeneratedField
withdb_persist=None
ordb_persist
not set. - Run the server or execute a command that requires the field validation.
- Observe that the code expects the value to be
True
orFalse
despite it being set toNone
.
Expected Behavior:
The db_persist
attribute should consistently accept None
throughout the code if it is defined as None=True
.
Actual Behavior:
The code expects db_persist
to be either True
or False
and does not handle the None
value appropriately.
Would fix https://github.com/typeddjango/django-stubs/pull/2568
According to the ticket's flags, the next step(s) to move this issue forward are:
- To improve the patch as described in the pull request review comments or on this ticket, then uncheck "Patch needs improvement".
If creating a new pull request, include a link to the pull request in the ticket comment when making that update. The usual format is:
[https://github.com/django/django/pull/#### PR]
.
Change History (1)
comment:1 by , 3 days ago
Description: | modified (diff) |
---|---|
Patch needs improvement: | set |
Summary: | GeneratedField.db_persist has None=True but it's still required to be set and True or False → GeneratedField.db_persist defaults to None but is required to be set as either True or False |
Triage Stage: | Unreviewed → Accepted |
Type: | Uncategorized → Cleanup/optimization |