Opened 16 years ago

Closed 16 years ago

Last modified 13 years ago

#9968 closed (fixed)

filter/exclude are broken on OneToOneField with primary_key=True

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

Description

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 by Malcolm Tredinnick, 16 years ago

Owner: changed from nobody to Malcolm Tredinnick
Status: newassigned

comment:2 by Jacob, 16 years ago

milestone: 1.1
Triage Stage: UnreviewedAccepted

comment:3 by Malcolm Tredinnick, 16 years ago

Resolution: fixed
Status: assignedclosed

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

comment:4 by Jacob, 13 years ago

milestone: 1.1

Milestone 1.1 deleted

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