From 98ce39b5a35c9d47b6c34764152fb3b1d2569c3e Mon Sep 17 00:00:00 2001
From: Egidijus Macijauskas <e.macijauskas@outlook.com>
Date: Thu, 11 Feb 2021 06:11:49 +0100
Subject: [PATCH] [3.2.x] Refs #19102 -- Removed flaky test
 Ticket19102Tests.test_ticket_19102_distinct_on.

The subquery pushdown only happens because another table is involved in
filter. It's not the distinct usage that causes the pushdown.

The distinct('description').order_by('pk') expression is not valid
because SELECT DISTINCT ON must match initial ORDER BY expressions
which is not the case here.

Backport of 4e8ecf0cb6ea36c45edb9cb86f0d63224e08097e from master
---
 tests/delete_regress/tests.py | 14 --------------
 1 file changed, 14 deletions(-)

diff --git a/tests/delete_regress/tests.py b/tests/delete_regress/tests.py
index a1bead144e..e4fa59e89f 100644
--- a/tests/delete_regress/tests.py
+++ b/tests/delete_regress/tests.py
@@ -291,20 +291,6 @@ class Ticket19102Tests(TestCase):
         self.assertFalse(Login.objects.filter(pk=self.l1.pk).exists())
         self.assertTrue(Login.objects.filter(pk=self.l2.pk).exists())
 
-    @skipUnlessDBFeature("update_can_self_select")
-    @skipUnlessDBFeature('can_distinct_on_fields')
-    def test_ticket_19102_distinct_on(self):
-        # Both Login objs should have same description so that only the one
-        # having smaller PK will be deleted.
-        Login.objects.update(description='description')
-        with self.assertNumQueries(1):
-            Login.objects.distinct('description').order_by('pk').filter(
-                orgunit__name__isnull=False
-            ).delete()
-        # Assumed that l1 which is created first has smaller PK.
-        self.assertFalse(Login.objects.filter(pk=self.l1.pk).exists())
-        self.assertTrue(Login.objects.filter(pk=self.l2.pk).exists())
-
     @skipUnlessDBFeature("update_can_self_select")
     def test_ticket_19102_select_related(self):
         with self.assertNumQueries(1):