Opened 8 years ago

Closed 7 years ago

Last modified 5 years ago

#9968 closed (fixed)

filter/exclude are broken on OneToOneField with primary_key=True

Reported by: gregoire Owned by: mtredinnick
Component: Database layer (models, ORM) Version: master
Severity: Keywords:
Cc: gregoire@… Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:


I would expect the following test to work :

from django.db import models

class Test(models.Model):
    >>> Test.objects.create()
    <Test: Test object>
class Test_A(models.Model):
    >>> Test.objects.filter(test_a=None)
    [<Test: Test object>]
    >>> Test.objects.exclude(test_a=None)
    model = models.OneToOneField(Test, primary_key=True)
class Test_B(models.Model):
    >>> Test.objects.filter(test_b=None)
    [<Test: Test object>]
    >>> Test.objects.exclude(test_b=None)
    model = models.OneToOneField(Test)

The only difference between Test_A and Test_B is the primary_key set on teh OneToOneField.

Test_A is broken : wrong result when using filter(), IndexError exception when using exclude()

Tested on r9701.

Change History (4)

comment:1 Changed 8 years ago by mtredinnick

  • Needs documentation unset
  • Needs tests unset
  • Owner changed from nobody to mtredinnick
  • Patch needs improvement unset
  • Status changed from new to assigned

comment:2 Changed 7 years ago by jacob

  • milestone set to 1.1
  • Triage Stage changed from Unreviewed to Accepted

comment:3 Changed 7 years ago by mtredinnick

  • Resolution set to fixed
  • Status changed from assigned to closed

Fixed in r9979 (I made a typo in the commit message).

comment:4 Changed 5 years ago by jacob

  • milestone 1.1 deleted

Milestone 1.1 deleted

Note: See TracTickets for help on using tickets.
Back to Top