mirror of
https://github.com/django/django.git
synced 2025-10-31 09:41:08 +00:00
Improved table join handling for comparisons against NULL.
This fixes a broad class of bugs involving filters that look for missing related models and fields. Most of them don't seem to have been reported (the added tests cover the root cause). The exception is that this has also fixed #9868. git-svn-id: http://code.djangoproject.com/svn/django/trunk@9979 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
@@ -33,6 +33,15 @@ class Favorites(models.Model):
|
||||
def __unicode__(self):
|
||||
return u"Favorites for %s" % self.name
|
||||
|
||||
class Target(models.Model):
|
||||
pass
|
||||
|
||||
class Pointer(models.Model):
|
||||
other = models.OneToOneField(Target, primary_key=True)
|
||||
|
||||
class Pointer2(models.Model):
|
||||
other = models.OneToOneField(Target)
|
||||
|
||||
__test__ = {'API_TESTS':"""
|
||||
# Regression test for #1064 and #1506: Check that we create models via the m2m
|
||||
# relation if the remote model has a OneToOneField.
|
||||
@@ -119,4 +128,17 @@ False
|
||||
>>> r.place == p
|
||||
True
|
||||
|
||||
# Regression test for #9968: filtering reverse one-to-one relations with
|
||||
# primary_key=True was misbehaving. We test both (primary_key=True & False)
|
||||
# cases here to prevent any reappearance of the problem.
|
||||
>>> _ = Target.objects.create()
|
||||
>>> Target.objects.filter(pointer=None)
|
||||
[<Target: Target object>]
|
||||
>>> Target.objects.exclude(pointer=None)
|
||||
[]
|
||||
>>> Target.objects.filter(pointer2=None)
|
||||
[<Target: Target object>]
|
||||
>>> Target.objects.exclude(pointer2=None)
|
||||
[]
|
||||
|
||||
"""}
|
||||
|
||||
Reference in New Issue
Block a user