Opened 8 days ago

Last modified 12 hours ago

#36262 assigned Cleanup/optimization

GeneratedField.db_persist has None=True but it's still required to be set and True or False — at Initial Version

Reported by: Jason Cameron Owned by: Jason Cameron
Component: Database layer (models, ORM) Version: dev
Severity: Normal Keywords:
Cc: Jason Cameron Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: yes
Easy pickings: yes UI/UX: no

Description

Description:
GeneratedField.db_persist attribute is set to None=True, 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:

  1. Create a model using GeneratedField with db_persist=None or db_persist not set.
  2. Run the server or execute a command that requires the field validation.
  3. Observe that the code expects the value to be True or False despite it being set to None.

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 (0)

Note: See TracTickets for help on using tickets.
Back to Top