Hi all, The Django Oracle documentation has the following to say about NULL and empty strings<https://docs.djangoproject.com/en/1.1/ref/databases/#null-and-empty-strings> (emphasis mine):
Django generally prefers to use the empty string ('') rather than NULL, but > Oracle treats both identically. To get around this, the Oracle backend > coerces the null=True option *on fields that have the empty string as a > possible value*. However, I've found that the Oracle schema that Django generates *always *allows NULLs on all string-like fields (CharField, TextField, FilePathField, etc). I'd assume that Django would only generate schemas where NULL is allowed for fields where blank=True, and that fields where blank=False would have "NOT NULL" included in the Oracle DDL. It appears that the Oracle backend looks at an undocumented "empty_strings_allowed" Field attribute to determine whether to output NOT NULL for the DDL. I've got a local patch to override the empty_strings_allowed field so that it's dependent on the Field's blank attribute, like so: @property > def empty_strings_allowed_if_blank(self): > return self.blank > models.fields.CharField.empty_strings_allowed = > empty_strings_allowed_if_blank models.fields.TextField.empty_strings_allowed = > empty_strings_allowed_if_blank [etc] This behavior feels like a bug in the Oracle backend that should be fixed, but I might be misunderstanding the documentation. I'm also unsure whether it's the Field subclasses that should patched or the Oracle backend that's in error. If someone could take a look so that Django 1.5 can have this fixed, that'd be great. Thanks! -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/8osie_BblHAJ. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.