mirror of
https://github.com/django/django.git
synced 2025-10-31 09:41:08 +00:00
Fixed #19720 -- Oracle ordering related delete regression
When a query had a complex where condition (a condition targeting more
than the base table) a subquery was used for deletion. However, the
query had default ordering from the model's meta and Oracle doesn't
work with ordered subqueries.
The regression was caused by fast-path deletion code introduced in
1cd6e04cd4 for fixing #18676.
Thanks to Dylan Klomparens for the report.
This commit is contained in:
@@ -10,7 +10,7 @@ from django.test import TestCase, TransactionTestCase, skipUnlessDBFeature
|
||||
from .models import (Book, Award, AwardNote, Person, Child, Toy, PlayedWith,
|
||||
PlayedWithNote, Email, Researcher, Food, Eaten, Policy, Version, Location,
|
||||
Item, Image, File, Photo, FooFile, FooImage, FooPhoto, FooFileProxy, Login,
|
||||
OrgUnit)
|
||||
OrgUnit, OrderedPerson, House)
|
||||
|
||||
|
||||
# Can't run this test under SQLite, because you can't
|
||||
@@ -347,3 +347,14 @@ class Ticket19102Tests(TestCase):
|
||||
self.assertFalse(Login.objects.filter(pk=self.l1.pk).exists())
|
||||
self.assertTrue(Login.objects.filter(pk=self.l2.pk).exists())
|
||||
|
||||
|
||||
class OrderedDeleteTests(TestCase):
|
||||
def test_meta_ordered_delete(self):
|
||||
# When a subquery is performed by deletion code, the subquery must be
|
||||
# cleared of all ordering. There was a but that caused _meta ordering
|
||||
# to be used. Refs #19720.
|
||||
h = House.objects.create(address='Foo')
|
||||
OrderedPerson.objects.create(name='Jack', lives_in=h)
|
||||
OrderedPerson.objects.create(name='Bob', lives_in=h)
|
||||
OrderedPerson.objects.filter(lives_in__address='Foo').delete()
|
||||
self.assertEqual(OrderedPerson.objects.count(), 0)
|
||||
|
||||
Reference in New Issue
Block a user