3 ms·
You never need a nullable string. If you must distinguish blank string from unset, add a column called “unset”. Using null for this will just result in bad data
by nerdponx 7y ago
You never need a nullable string. If you must distinguish blank string from unset, add a column called “unset”. Using null for this will just result in bad data entry.
What's an example of a data entry error that results from this scenario? Wouldn't it entirely depend on the data entry interface?
- earthboundkid 7y agoSomeone is filling out the form. They skip MI. Do I mark it as null or blank? The only way to trust this is to have a big check mark that say “does not have a middle initial” that stores a boolean. But realistically, who cares? Unless you’re dealing with legal names, you don’t need to distinguish the cases.
- nerdponx 7y agoOK, but why does that require the database to have non-nullable string types?
- earthboundkid 7y agoNo reason per se, but it’s inconvenient and I’ve seen tons of bugs from “NoneType has no method ‘uppercase()’” that this eliminates.
- nerdponx 7y agoSorry, I can't get behind changing the database design to accommodate under-specified data contracts and/or lazy software development.
- earthboundkid 7y agoI can't get behind letting theoretical database design concerns trump real world problems with unexpected nulls leading to 500s in production. :-)