wow, that's interesting. I was not aware if this.

So, coming to the real question, here is my use case which raised this
questions:

I've a class in the model with two CharFields. When validating data
inputs, I need to check that, if the user filled field A, then also
field B should contains some value

- model definition

class MyClass(models.Model):
    ...
   A = models.CharField(max_length=20)
   B = models.CharField(max_length=20)
   ...

- validation
   ...
 A = cleaned_data.get("A")
 B = cleaned_data.get("B")
 if A != "" and B == "":
     self._errors["B"] = ErrorList(["B must be filled because A is
filled"])

is this ok and independent from all DB backends as opposed to  (if A
is not None and B is None) which seems not work?


Cheers, Sergio





On Mar 14, 3:58 am, Malcolm Tredinnick <malc...@pointy-stick.com>
wrote:
> On Fri, 2009-03-13 at 19:29 -0700, Sergio wrote:
>
> > On Mar 14, 2:23 am, Malcolm Tredinnick <malc...@pointy-stick.com>
> > wrote:
> > > Character fields in Django can never be NULL. They will either be empty
> > > (and stored as '') or not empty, but never stored as NULL in the
> > > database.
>
> > thanks for your answer. Could you please give more insight on this
> > note?
>
> > "When using the Oracle database backend, the null=True option will be
> > coerced for string-based fields that have the empty string as a
> > possible value, and the value NULL will be stored to denote the empty
> > string."
>
> It's an implementation detail that makes no difference in practice. It
> talks about what is sent to the database, not how it looks at the Django
> level.
>
> Oracle has a long-standing bug in their SQL implementation in that ''
> and NULL compare as equal (they won't fix it because it would break
> untold amounts of existing code in their customers' applications), so
> NULL / '' handling in things talking to Oracle databases is almost the
> exact opposite of fun. Django hides that pain from you for the most
> part. The note indicates that if you looked at the field object in the
> model when using the Oracle backend, you would  see null=True (so it's
> not entirely transparent).
>
> Regards,
> Malcolm
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
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