Ticket #12192: 12192.diff

File 12192.diff, 2.0 KB (added by Ramiro Morales, 14 years ago)

Patch for review

  • django/db/backends/oracle/compiler.py

    diff --git a/django/db/backends/oracle/compiler.py b/django/db/backends/oracle/compiler.py
    a b  
    2727        If 'with_limits' is False, any limit/offset information is not
    2828        included in the query.
    2929        """
     30        if with_limits and self.query.low_mark == self.query.high_mark:
     31            return '', ()
    3032
    3133        # The `do_offset` flag indicates whether we need to construct
    3234        # the SQL needed to use limit/offset with Oracle.
  • django/db/models/sql/compiler.py

    diff --git a/django/db/models/sql/compiler.py b/django/db/models/sql/compiler.py
    a b  
    5252        If 'with_limits' is False, any limit/offset information is not included
    5353        in the query.
    5454        """
     55        if with_limits and self.query.low_mark == self.query.high_mark:
     56            return '', ()
     57
    5558        self.pre_sql_setup()
    5659        out_cols = self.get_columns(with_col_aliases)
    5760        ordering, ordering_group_by = self.get_ordering()
  • tests/regressiontests/queries/tests.py

    diff --git a/tests/regressiontests/queries/tests.py b/tests/regressiontests/queries/tests.py
    a b  
    8686    def test_emptyqueryset_values(self):
    8787        "#14366 -- calling .values() on an EmptyQuerySet and then cloning that should not cause an error"
    8888        self.assertEqual(list(Number.objects.none().values('num').order_by('num')), [])
    89    
     89
    9090    def test_values_subquery(self):
    9191        self.assertQuerysetEqual(
    9292            Number.objects.filter(pk__in=Number.objects.none().values("pk")), []
    9393        )
     94
     95
     96class WeirdQuerySetSlicing(TestCase):
     97    def setUp(self):
     98        Number.objects.create(num=1)
     99        Number.objects.create(num=2)
     100
     101    def test_empty_resultset_sql(self):
     102        # ticket #12192
     103        def run():
     104            list(Number.objects.all()[1:1])
     105        self.assertNumQueries(0, run)
Back to Top