1.8.x - Fix evaluation of zero-length query slices

Declined
#10 · Created  · Last updated

Declined pull request

Manually merged patch to Query. 61341def25f1d4829f4a7984b26109cc8d04f7e8

Closed by: ·2016-08-25

Description

See Django #25894. A bug occurs for zero-length slices of a QuerySet (e.g., Model.objects.all()[0:0]). It was a bug in Django 1.9 that was fixed in an early point release, but the bug can be seen using Oracle and, apparently, MSSQL backends on Django 1.8.

This Django PR fixed the problem for Oracle on Django >= 1.9: https://github.com/django/django/pull/5834

Since the above PR was not backported to 1.8, I had to monkey-patch the Query class to fully fix the problem on my project:

def set_limits(self, low=None, high=None): self._original_set_limits(low, high) if self.low_mark == self.high_mark: self.set_empty() from django.db.models.sql.query import Query Query._original_set_limits = Query.set_limits Query.set_limits = set_limits

0 attachments

0 comments

Loading commits...