Re: CharField with Oracle Backend Null Behaviour

2019-02-13 Thread Dan Davis
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 the curren

Re: CharField with Oracle Backend Null Behaviour

2018-11-12 Thread vafzal
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 ch

Re: CharField with Oracle Backend Null Behaviour

2018-11-08 Thread Dan Davis
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

Re: CharField with Oracle Backend Null Behaviour

2018-11-08 Thread Mariusz Felisiak
Hi, 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 https://docs.djangoproject.com/en/2.1/ref/databases/#null-and-empty-strings). I don't see much value in changing

Re: CharField with Oracle Backend Null Behaviour

2018-11-08 Thread vafzal
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 nulls

Re: CharField with Oracle Backend Null Behaviour

2018-11-08 Thread Florian Apolloner
Hi Vackar, Thank you, now we are getting somewhere! On Thursday, November 8, 2018 at 5:36:53 PM UTC+1, vaf...@exscientia.co.uk wrote: > > 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 > pref

Re: CharField with Oracle Backend Null Behaviour

2018-11-08 Thread vafzal
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 t

Re: CharField with Oracle Backend Null Behaviour

2018-11-08 Thread vafzal
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 t

Re: CharField with Oracle Backend Null Behaviour

2018-11-08 Thread Florian Apolloner
On Thursday, November 8, 2018 at 3:52:01 PM UTC+1, vaf...@exscientia.co.uk wrote: > > - 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 co

Re: CharField with Oracle Backend Null Behaviour

2018-11-08 Thread vafzal
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 Th

Re: CharField with Oracle Backend Null Behaviour

2018-11-08 Thread vafzal
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 c

Re: CharField with Oracle Backend Null Behaviour

2018-11-08 Thread Václav Řehák
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: class NonEmp

Re: CharField with Oracle Backend Null Behaviour

2018-11-08 Thread Florian Apolloner
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 proposing here… -- You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group