diff --git a/django/db/backends/oracle/compiler.py b/django/db/backends/oracle/compiler.py
a
|
b
|
|
27 | 27 | If 'with_limits' is False, any limit/offset information is not |
28 | 28 | included in the query. |
29 | 29 | """ |
| 30 | if with_limits and self.query.low_mark == self.query.high_mark: |
| 31 | return '', () |
30 | 32 | |
31 | 33 | # The `do_offset` flag indicates whether we need to construct |
32 | 34 | # the SQL needed to use limit/offset with Oracle. |
diff --git a/django/db/models/sql/compiler.py b/django/db/models/sql/compiler.py
a
|
b
|
|
52 | 52 | If 'with_limits' is False, any limit/offset information is not included |
53 | 53 | in the query. |
54 | 54 | """ |
| 55 | if with_limits and self.query.low_mark == self.query.high_mark: |
| 56 | return '', () |
| 57 | |
55 | 58 | self.pre_sql_setup() |
56 | 59 | out_cols = self.get_columns(with_col_aliases) |
57 | 60 | ordering, ordering_group_by = self.get_ordering() |
diff --git a/tests/regressiontests/queries/tests.py b/tests/regressiontests/queries/tests.py
a
|
b
|
|
86 | 86 | def test_emptyqueryset_values(self): |
87 | 87 | "#14366 -- calling .values() on an EmptyQuerySet and then cloning that should not cause an error" |
88 | 88 | self.assertEqual(list(Number.objects.none().values('num').order_by('num')), []) |
89 | | |
| 89 | |
90 | 90 | def test_values_subquery(self): |
91 | 91 | self.assertQuerysetEqual( |
92 | 92 | Number.objects.filter(pk__in=Number.objects.none().values("pk")), [] |
93 | 93 | ) |
| 94 | |
| 95 | |
| 96 | class 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) |