Hi all,
I ran into troubles yesterday with a piece of code which had to find
duplicate entries in the database:
duplicates = Foo.objects.exclude(id=self.id).filter(bar=self.bar)
which of course works as expected UNLESS called in freshly created
instance, where self.id is None.
Few seconds later I found a note about __isnull in documentation, but
the syntax above is so intuitive, that someone may first think there's
a bug in django. I was confused even with raw SQL in front of my eyes
- I just didn't know that 'NOT bar = NULL' is not the same as 'bar IS
NOT NULL'.
Anyway, seems that any query with field=None just doesn't make any
sense and, if used by anyone, is meant to do the same as
field__isnull=False. Wouldn't it be a good idea to convert such
queries to field__isnull=False equivalent in Model class? Correct me
if I'm wrong, please.
Cheers,
--
Michał Sałaban <michal(at)salaban.info>
jabber: michal.salaban(at)gmail.com
sip: emes(at)ekiga.net
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-developers?hl=en
-~----------~----~----~----~------~----~------~--~---