Hi all,

The Oracle database backend has the following note about NULLs vs empty 
strings (emphasis  is mine):

Django generally prefers to use the empty string ('') rather than NULL, but 
> Oracle treats both identically. To get around this, the Oracle backend 
> ignores an *explicit null option on fields that have the empty string as 
> a possible value* and generates DDL as if null=True.


However, I've found that the Oracle backend *always *generates NULLs for 
string-like fields (i.e. CharField and friends, such as TextField and 
FilePathField). In other words, it's permitting NULLs for fields where 
null=False and blank=False, which is odds with the documentation.

For a possible fix, I've got a patch in my Django working copy where 
Field.empty_strings_allowed becomes dynamic, based on whether a Field's 
blank option is true. It's pretty basic:

@property
> def empty_strings_allowed_if_blank(self):
>     return self.blank
> models.fields.CharField.empty_strings_allowed = 
> empty_strings_allowed_if_blank


Is this a reasonable solution? I apologize if I'm misunderstanding the 
documentation and this isn't a bug.

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/-/sUMb7pGYhP4J.
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.

Reply via email to