Opened 17 years ago

Closed 17 years ago

#6026 closed (invalid)

strange behavior of exclude() and multiple fields

Reported by: Michael Samoylov <michael.samoylov@…> Owned by: nobody
Component: Database layer (models, ORM) Version: 0.96
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

class Consumer(models.Model):
    user = models.ForeignKey(User, core=True, editable=False)
    [skipped]

class Trip(models.Model):
    consumer = models.ForeignKey(Consumer, related_name='consumer', blank=True, null=True, editable=False)
    legacy = models.BooleanField(default=False)  # used to flag old-style trip
    [skipped]   
>>> for t in Trip.objects.exclude(legacy=True):
...     if t.legacy is True:
...         print t.id
...         break
...
>>> for t in Trip.objects.exclude(consumer__user__email__contains='@yahoo.com ', legacy=True):
...     if t.legacy is True:
...         print t.id
...         break
...
34933
>>> for t in Trip.objects.exclude(consumer__user__email__icontains='@yahoo.com', legacy=True):
...     if t.legacy is True:
...         print t.id
...         break
...
34933
>>> for t in Trip.objects.exclude (consumer__user__email__endswith='@yahoo.com', legacy=True):
...     if t.legacy is True:
...         print t.id
...         break
...
34933
>>> for t in Trip.objects.exclude(duration=1, legacy=True):
...     if t.legacy is True:
...         print t.id
...         break
...
>>>
>>> for t in Trip.objects.filter(consumer__user__email__endswith='@yahoo.com', legacy=False):
...     if t.legacy is True:
...         print t.id
...         break
...
>>>
>>> for t in Trip.objects.exclude(consumer__user__email__endswith='@yahoo.com').exclude(legacy=True):
...     if t.legacy is True:
...         print t.id
...         break
...
>>>

Change History (2)

comment:1 by Malcolm Tredinnick, 17 years ago

As much as I like reading code, could you please provide a short description of the problem. Which cases do you think are in error and what should the expected results be. Some of the examples you've shown use fields not in your model and we don't know the initial data you are querying.

So this is too difficult to reliably debug based on the information given at the moment.

comment:2 by MichaelBishop, 17 years ago

Resolution: invalid
Status: newclosed

Not enough information provided to understand why this is a bug.

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