Opened 7 years ago

Closed 7 years ago

Last modified 4 years ago

#8063 closed (fixed)

Taking a slice of a queryset does not respect extra(...)

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

Description (last modified by mtredinnick)

If you do a qs as the following:

>>> foo = MyObjects.objects.all().extra(select={'relevance': match_expr}, where=[match_expr], params=[query])
>>> print foo
>>> bar = MyObjects.objects.all().extra(select={'relevance': match_expr}, where=[match_expr], params=[query])

>>> print bar[:10]

The first 10 elements of foo may not match bar, bar will simply be the first 10 objects and it discards the extra where clause.

Change History (7)

comment:1 Changed 7 years ago by mattmcc

  • Component changed from Uncategorized to Database wrapper
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

comment:2 Changed 7 years ago by adamfast

  • milestone set to 1.0
  • Triage Stage changed from Unreviewed to Accepted

comment:3 Changed 7 years ago by mtredinnick

  • Description modified (diff)

comment:4 Changed 7 years ago by mtredinnick

  • Summary changed from Taking a slice of a queryset with extras specified alters the query to Taking a slice of a queryset does not respect extra(...)

Changing the description, because I keep seeing it in summaries and thinking "of course it does. Otherwise there would be no point!", which isn't really what the problem is about.

comment:5 Changed 7 years ago by mtredinnick

(In [8427]) Added a test to show that #8063 doesn't seem to be an issue any longer.
Refs #8063.

comment:6 Changed 7 years ago by mtredinnick

  • Resolution set to fixed
  • Status changed from new to closed

I cannot duplicate this in any fashion. In [8427], I've added a test in case to make sure this doesn't become an issue again, but it seems to have been fixed by something in the interim.

If anybody thinks it still exists, please create a modification of the above test to show the problem so that we have some repeatable to debug (the original report in this ticket doesn't details on a concrete test, since information about match_expr and so forth are missing).

comment:7 Changed 4 years ago by jacob

  • milestone 1.0 deleted

Milestone 1.0 deleted

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