mirror of
https://github.com/django/django.git
synced 2025-08-03 18:38:50 +00:00
Fixed #19964 -- Removed relabel_aliases from some structs
Before there was need to have both .relabel_aliases() and .clone() for many structs. Now there is only relabeled_clone() for those structs where alias is the only mutable attribute.
This commit is contained in:
parent
679af4058d
commit
d744c550d5
9 changed files with 79 additions and 105 deletions
|
@ -25,7 +25,7 @@ from .models import (Annotation, Article, Author, Celebrity, Child, Cover,
|
|||
SpecialCategory, OneToOneCategory, NullableName, ProxyCategory,
|
||||
SingleObject, RelatedObject, ModelA, ModelD, Responsibility, Job,
|
||||
JobResponsibilities, BaseA, Identifier, Program, Channel, Page, Paragraph,
|
||||
Chapter, Book)
|
||||
Chapter, Book, MyObject)
|
||||
|
||||
|
||||
class BaseQuerysetTest(TestCase):
|
||||
|
@ -2661,3 +2661,17 @@ class ManyToManyExcludeTest(TestCase):
|
|||
self.assertNotIn(b1, q)
|
||||
self.assertIn(b2, q)
|
||||
self.assertIn(b3, q)
|
||||
|
||||
class RelabelCloneTest(TestCase):
|
||||
def test_ticket_19964(self):
|
||||
my1 = MyObject.objects.create(data='foo')
|
||||
my1.parent = my1
|
||||
my1.save()
|
||||
my2 = MyObject.objects.create(data='bar', parent=my1)
|
||||
parents = MyObject.objects.filter(parent=F('id'))
|
||||
children = MyObject.objects.filter(parent__in=parents).exclude(parent=F('id'))
|
||||
self.assertEqual(list(parents), [my1])
|
||||
# Evaluating the children query (which has parents as part of it) does
|
||||
# not change results for the parents query.
|
||||
self.assertEqual(list(children), [my2])
|
||||
self.assertEqual(list(parents), [my1])
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue