Opened 6 months ago

Closed 5 months ago

#36262 closed Cleanup/optimization (fixed)

GeneratedField.db_persist defaults to None but is required to be set as either True or False

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

Description (last modified by Sarah Boyce)

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:

  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

Change History (6)

comment:1 by Sarah Boyce, 6 months 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 FalseGeneratedField.db_persist defaults to None but is required to be set as either True or False
Triage Stage: UnreviewedAccepted
Type: UncategorizedCleanup/optimization

comment:2 by Ponnapula Gangothri, 6 months ago

I’d like to work on this. Could you confirm if this is still available?

comment:3 by Jacob Walls, 6 months ago

At this point it's not -- there's an owner and a linked PR (see the fields in the ticket metadata).

comment:4 by Jason Cameron, 6 months ago

Yeah, I'm just waiting for the PR to be merged-

comment:5 by Sarah Boyce, 5 months ago

Patch needs improvement: unset
Triage Stage: AcceptedReady for checkin

comment:6 by Sarah Boyce <42296566+sarahboyce@…>, 5 months ago

Resolution: fixed
Status: assignedclosed

In 9608678:

Fixed #36262 -- Made GeneratedField.db_persist a required key-word argument.

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