Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
keeganland opened this issue Jul 6, 2021 · 0 comments
Open

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

keeganland opened this issue Jul 6, 2021 · 0 comments

Comments

@keeganland
Copy link
Contributor

keeganland commented Jul 6, 2021

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".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant