Opened 13 years ago

Closed 13 years ago

#16290 closed Bug (invalid)

slicing in subquery on MySQL DB — at Version 1

Reported by: anonymous 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 (last modified by Ramiro Morales)

When I do slicing on a query, and the use that result as a subquery I get the following error, when using MySQL:

"This version of MySQL doesn't yet support'LIMIT & IN/ALL/ANY/SOME subquery'"

objects = Model.objects.filter(key=value).values_list('id', flat=True)[:4]
Model.objects.filter(id!__in=objects)

Of course this example makes no sense.
But the workaround I did, was to force django to evaluate the first query, and then use the result as input for the next. Maybe this should be the default, since MySQL doesn't support the action. Or atleast Django should explain the solution of forcing evaluating, and the slowdowns, that might have.(Have no idea if that's the case.)

Change History (1)

in reply to:  description comment:1 by Ramiro Morales, 13 years ago

Description: modified (diff)
Resolution: invalid
Status: newclosed

Replying to anonymous:

[...] Or atleast Django should explain the solution of forcing evaluating, and the slowdowns, that might have.(Have no idea if that's the case.)

It already does (see the Performance considerations box):

https://docs.djangoproject.com/en/1.3/ref/models/querysets/#in

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