Opened 8 years ago

Closed 8 years ago

Last modified 5 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 Malcolm Tredinnick)

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 8 years ago by Matt McClanahan

Component: UncategorizedDatabase wrapper
Needs documentation: unset
Needs tests: unset
Patch needs improvement: unset

comment:2 Changed 8 years ago by adamfast

milestone: 1.0
Triage Stage: UnreviewedAccepted

comment:3 Changed 8 years ago by Malcolm Tredinnick

Description: modified (diff)

comment:4 Changed 8 years ago by Malcolm Tredinnick

Summary: Taking a slice of a queryset with extras specified alters the queryTaking 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 8 years ago by Malcolm Tredinnick

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

comment:6 Changed 8 years ago by Malcolm Tredinnick

Resolution: fixed
Status: newclosed

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 5 years ago by Jacob

milestone: 1.0

Milestone 1.0 deleted

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