Hi Mariusz,
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
Hi Florian,
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
Vaclav,
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
Hi Florian
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
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
really useful.
Would probably call it RequiredCharField though, the double negative in
NonEmptyCharField can make it a slightly harder to read.
On
Hi Florian,
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
- When
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
Dear Django Team,
The current behaviour of Django with an Oracle backend is to ignore the
null parameter on CharFields. The implication of this is that all text
fields are effectively optional, with the justification being that Oracle
treats nulls and empty strings in a similar manner. I don't