adfinis/timed

[ENHANCEMENT]: DJ001 avoid using null=True on string-based fields such as CharField

hairmare opened this issue · 1 comments

DJ001:

Warning

DJ001 Avoid using null=True on string-based fields such as CharField

It would require a migration (if the null=True) gets dropped and might break something (don't know for sure tho)

Originally posted by @c0rydoras in adfinis/timed-backend#1049 (comment)

Lets take the discussion on this rule here... In adfinis/timed-backend#1049 (comment) @winged posits that this is just dogmatically trying to satisfy the linter. The ruleset on the other hands tells us

If a string-based field is nullable, then your model will have two possible representations for "no data": None and the empty string. This can lead to confusion, as clients of the API have to check for both None and the empty string when trying to determine if the field has data.

The Django convention is to use the empty string in lieu of None for string-based fields.

In our case we could have a look at some client code to see if both forms are checked (given it's what the rule wants to prevent) or it might even be that the issue isn't exposed and the confusion is reverted during serialization.