Django

Code

Ticket #2253 (closed: fixed)

Opened 2 years ago

Last modified 3 weeks ago

Combining QuerySets via | operator does not always work

Reported by: jeffrey.a.zelt@vm.ntnu.no Assigned to: anonymous
Component: Database wrapper Version: SVN
Keywords: qs-rf-fixed Cc: mir@noris.de
Triage Stage: Accepted Has patch: 0
Needs documentation: 0 Needs tests: 1
Patch needs improvement: 0

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.

Attachments

Change History

06/28/06 05:42:11 changed by mir@noris.de

  • cc set to mir@noris.de.

02/21/07 15:02:34 changed by SmileyChris

  • needs_tests set to 1.
  • stage changed from Unreviewed to Accepted.

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

06/07/07 16:57:17 changed by adrian

  • version changed from magic-removal to SVN.

09/13/07 16:35:40 changed by mtredinnick

  • keywords set to qs-rf-fixed.

11/30/07 22:54:57 changed by ionut_bizau

  • owner changed from nobody to ionut_bizau.
  • status changed from new to assigned.

12/01/07 02:16:15 changed by ionut_bizau

  • owner deleted.
  • status changed from assigned to new.

02/17/08 06:20:18 changed by anonymous

  • owner set to anonymoulfjkfs.

02/17/08 13:50:07 changed by SmileyChris

  • owner changed from anonymoulfjkfs to anonymous.

04/26/08 21:50:16 changed by mtredinnick

  • status changed from new to closed.
  • resolution set to fixed.

(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


Add/Change #2253 (Combining QuerySets via | operator does not always work)




Change Properties
Action