Code

Opened 3 years ago

Closed 3 years ago

Last modified 3 years ago

#17176 closed Bug (worksforme)

Problem when retrieving objects with AND over multiple OR statements

Reported by: hanson2010 Owned by: nobody
Component: Database layer (models, ORM) Version: 1.3
Severity: Normal 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

I'm using Django 1.3 on MongoDB, and met a weird situation.

Project.objects.filter(

Q(owner=u'A') | Q(owner=u'B'),
Q(owner=u'C') | Q(owner=u'D'),

)

The above returned queryset is same to Project.objects.filter(Q(owner=u'C') | Q(owner=u'D')), but not None, as expected. It seems that the first half lookup function was omitted.

Does someone know that it's problem with Django or third-party mongodb-engine libraries? Thanks in ad!

Attachments (0)

Change History (2)

comment:1 Changed 3 years ago by aaugustin

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to worksforme
  • Status changed from new to closed

It isn't a problem with Django:

>>> AutoName.objects.all()
[<AutoName: A>, <AutoName: C>]
>>> AutoName.objects.filter(Q(name=u'A') | Q(name=u'B'), Q(name=u'C') | Q(name=u'D'))
[]
>>> AutoName.objects.filter(Q(name=u'A') | Q(name=u'B'))
[<AutoName: A>]
>>> AutoName.objects.filter(Q(name=u'C') | Q(name=u'D'))
[<AutoName: C>]

(example with the models from https://bitbucket.org/aaugustin/django-tz-demo)

comment:2 Changed 3 years ago by hanson2010

Thanks for your quick input. Then what is the related package? Any advice is appreciated!

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.