3 ms·
Open question re: django: https://docs.djangoproject.com/en/2.1/ref/models/fields/#null https://docs.djangoproject.com/en/2.1/ref/models/fields/#nul... I've g
by lowercased 8y ago
Open question re: django:
https://docs.djangoproject.com/en/2.1/ref/models/fields/#null https://docs.djangoproject.com/en/2.1/ref/models/fields/#nul...
I've got a colleague who has been using django for a couple of years (and has 15+ years experience with python outside of web, as well as java, php, arduino hacking, 3d printing, etc).
He pointed me to the link above re: nulls - I can't figure out why the default would be to convert a null to an empty string. All major databases can understand nulls just fine.
"... If a string-based field has null=True, that means it has two possible values for “no data”: NULL, and the empty string. In most cases, it’s redundant to have two possible values for “no data;”..."
An empty string is "no user supplied data" and a null is "no value has been given at all". It seems rather ... odd(?) to try to conflate the two.
Am I missing something?
I've got perhaps a slight bias against django, in that the only people I've known who've used it were either junior devs who had no experience in anything else (and raved about it), or senior folks who've inherited a relative django mess (usually the result of the aforementioned junior devs).
- caspar 8y ago> An empty string is "no user supplied data" and a null is "no value has been given at all" I assume you meant "an empty string is user supplied an empty string as data". That aside, you wouldn't normally switch that option on for a field (notice the default is false). However, Oracle DB stores empty strings as indistinguishable from NULLs[0], so an ORM supporting Oracle DB may want to have some support for converting "empty or null" to an empty string at read time (notice the Oracle specific caveat in the docs in your link). Once you have that, I'd guess the thinking is that you may as well let devs opt into that behavior (bear in mind that sometimes you're in the position of developing a new app against an existing db, that may or may not have another legacy app reading/writing from it at the same time). 0: https://stackoverflow.com/questions/203493/why-does-oracle-9i-treat-an-empty-string-as-null/203536#203536 https://stackoverflow.com/questions/203493/why-does-oracle-9...
- lowercased 8y ago> I assume you meant "an empty string is user supplied an empty string as data". I think so - it was a bit late. But it's the diff between intentional empty value and unknown/initial value. I still don't grok why django seems to want, by default, to ignore the concept of storing "null" in the database, and makes you jump to non-default configuration to do something which has value (seeing nulls vs empty strings means different things).