#36262: GeneratedField.db_persist has None=True but it's still required to be 
set
and True or False
-------------------------------------+-------------------------------------
               Reporter:  Jason      |          Owner:  Jason Cameron
  Cameron                            |
                   Type:             |         Status:  assigned
  Uncategorized                      |
              Component:  Database   |        Version:  dev
  layer (models, ORM)                |
               Severity:  Normal     |       Keywords:
           Triage Stage:             |      Has patch:  1
  Unreviewed                         |
    Needs documentation:  0          |    Needs tests:  0
Patch needs improvement:  0          |  Easy pickings:  1
                  UI/UX:  0          |
-------------------------------------+-------------------------------------
 **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
-- 
Ticket URL: <https://code.djangoproject.com/ticket/36262>
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 visit 
https://groups.google.com/d/msgid/django-updates/01070195a46fe70e-b0619ee9-e189-4a77-9fab-f50c03bb7361-000000%40eu-central-1.amazonses.com.

Reply via email to