slicing in subquery on MySQL DB
|Reported by:||anonymous||Owned by:||nobody|
|Component:||Database layer (models, ORM)||Version:||1.3|
|Has patch:||no||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
Description (last modified by ramiro)
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.)