Skip to content

Dispatch deliberately allows multiple entries for "null" fields #991

Open
@keeganland

Description

@keeganland

Here is an example in class Subsection:

description = TextField(null=True, blank=True)

Now, say a customized React form exists for this field and some backend programmer wants to check if it's empty by checking if it's not equal to the empty string. Depending how the form was programmed, certain boolean checks may pass and others fail in an unpredictable way, because when the field is unfilled it may more may not be stringlike.

I've had unexpected exceptions when writing code to get data from Dispatch because of this.

Django convention is to never allow null=True on a TextField or CharField unless circumstances demand it. Rather, blank=True, but with default='', is preferred. This guarantees when the SQL table is supposed to store data that should be interpreted as a string by Python, we don't end up needing to do checks that guarantee our object is sufficiently string-like to do the operations we need; its type is string, not "string or null".

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions