Opened 18 years ago

Closed 17 years ago

#2253 closed defect (fixed)

Combining QuerySets via | operator does not always work

Reported by: jeffrey.a.zelt@… Owned by: anonymous
Component: Database layer (models, ORM) Version: dev
Severity: major Keywords: qs-rf-fixed
Cc: mir@… Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: yes Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

I am working through the first example model in the documentation (http://www.djangoproject.com/documentation/models/basic/). Using that model as a reference, I can show the output here from the python interpeter that where the "|" operator generates an incorrect result (but the "&" operator seems to work OK):

all = Article.objects.all()
one = Article.objects.filter(id=1)

all

[<Article: Area womman programs in Python>, <Article: Second article>, <Article: Third article>, <Article: Fourth article>, <Article: Article 6>, <Article: Default headline>, <Article: Article 7>, <Article: Article 8>, <Article: Article 9>, <Article: Article 7>]

one

[<Article: Area womman programs in Python>]

all | one

[<Article: Area womman programs in Python>] <-- should be the union of the two QuerySets, but it is not

all & one

[<Article: Area womman programs in Python>]

The operation: "all | one" should have been the union of these two ResultSets, but here it is a list containing only a single object. Note that the intersection "all & one" is, however, correct. Here are a few more details:

import django
django.VERSION

(0, 95, 'post-magic-removal')

Specifically, this is for revision 3214.

Change History (9)

comment:1 by mir@…, 18 years ago

Cc: mir@… added

comment:2 by Chris Beaven, 18 years ago

Needs tests: set
Triage Stage: UnreviewedAccepted

mir, care to write up a test (if not the whole patch ;))

comment:3 by Adrian Holovaty, 17 years ago

Version: magic-removalSVN

comment:4 by Malcolm Tredinnick, 17 years ago

Keywords: qs-rf-fixed added

comment:5 by ionut bizau, 17 years ago

Owner: changed from nobody to ionut bizau
Status: newassigned

comment:6 by ionut bizau, 17 years ago

Owner: ionut bizau removed
Status: assignednew

comment:7 by anonymous, 17 years ago

Owner: set to anonymoulfjkfs

comment:8 by Chris Beaven, 17 years ago

Owner: changed from anonymoulfjkfs to anonymous

comment:9 by Malcolm Tredinnick, 17 years ago

Resolution: fixed
Status: newclosed

(In [7477]) Merged the queryset-refactor branch into trunk.

This is a big internal change, but mostly backwards compatible with existing
code. Also adds a couple of new features.

Fixed #245, #1050, #1656, #1801, #2076, #2091, #2150, #2253, #2306, #2400, #2430, #2482, #2496, #2676, #2737, #2874, #2902, #2939, #3037, #3141, #3288, #3440, #3592, #3739, #4088, #4260, #4289, #4306, #4358, #4464, #4510, #4858, #5012, #5020, #5261, #5295, #5321, #5324, #5325, #5555, #5707, #5796, #5817, #5987, #6018, #6074, #6088, #6154, #6177, #6180, #6203, #6658

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