This very issue of a not-null constraint causes a problem with
django-silk. I'm not sure this matters in practice, because the usage of
django silk is usually for development; I just added an sqlite3 database
alias and a router for django-silk. However, it validates the problem of
Thanks for getting back to me, didn't realise that default was empty
strings, that would work too. With regards to existing projects, migration
should be really straightforward, just need to add a constraint to db on
the next migration. It would generate migrations where no model
Part of the reason to use Django is to assure some level of database
portability. I use Oracle exclusively at work, although there are some
plans to move towards PostgreSQL. I think blank=True should govern whether
the field may be null or not.
So, from my perspective, we should limit ourselves
Oracle treats empty strings and NULLs in the same way, that's why we
had to decide on some workaround that will cover both python's (other Dbs')
cases i.e. NULLs and "" (see
I don't see much value in
Yes you are correct, backwards compatibility would break with this change.
As Django already mimics the required checks in middleware for nulls, only
difference I can see going forward would be that newly inserted blank
strings would be read back back as None, instead of '' if
Thank you, now we are getting somewhere!
On Thursday, November 8, 2018 at 5:36:53 PM UTC+1, vaf...@exscientia.co.uk
> My main concern currently is that required fields are not enforced at the
> db level, which makes using it with other clients difficult. I would much
With your approach, fields are correctly created with / without null
constraints based on the value of the 'null' parameter.
However subsequent changes are not being picked up by the migrations
framework. i.e. if I change null=True to null=False, constraint is not
dropped. The same is
No probs, most people don't understand Oracle, it's a bit of a black art.
Some background: Partly for legacy and partly for justifiable reasons,
oracle converts blank strings to null.
Back to this issue, as you say, if you implemented the above
recommendations you would not be able
On Thursday, November 8, 2018 at 3:52:01 PM UTC+1, vaf...@exscientia.co.uk
> - If null=False is specified, then add an explicit not null constraint at
> the db level
As far as I understand Oracle makes no difference between null and an empty
string. So if we were to add a not-null
Vaclav, this is an interesting approach. I know it's a very simple field,
but have you though of creating an open source package for this, looks
Would probably call it RequiredCharField though, the double negative in
NonEmptyCharField can make it a slightly harder to read.
Thanks for getting back to me. Allow me elaborate
My main question is: what is the rationale for enforcing null value checks
in middleware, and not delegating to DB?
My proposal would be:
- If null=False is specified, then add an explicit not null constraint at
the db level
While it is probably not possible to change how Django treats this, many
newcomers find it super confusing. To make developer experience in our
Oracle-based project better, we started using the following workaround for
fields which are required to be not null and not empty string:
Oracle treats NULL and empty varchar2 the same; so null=True/False is
simply not possible on Oracle for CharField. I am not sure what you are
You received this message because you are subscribed to the Google Groups
"Django developers (Contributions to Django itself)"
Dear Django Team,
CharField on an Oracle backend has some strange behaviour. Because oracle
treats empty strings and nulls in a similar fashion, Django simply ignore
the null parameter (which should control nullability) on the field.
I agree that an empty string and a null value are under most
Mail list logo