[1.8.x] Reverted "Fixed #27594 -- Fixed select_related() with reverse self-referential OneToOneField."
This reverts commit 4a9f9cc521f09c60f56024eb6688e30ab86b998f. It was accidentally pushed to this branch.
This commit is contained in:
parent
4a9f9cc521
commit
01b3dc2232
@ -724,7 +724,7 @@ class SQLCompiler(object):
|
|||||||
|
|
||||||
_, _, _, joins, _ = self.query.setup_joins([related_field_name], opts, root_alias)
|
_, _, _, joins, _ = self.query.setup_joins([related_field_name], opts, root_alias)
|
||||||
alias = joins[-1]
|
alias = joins[-1]
|
||||||
from_parent = issubclass(model, opts.model) and model is not opts.model
|
from_parent = issubclass(model, opts.model)
|
||||||
klass_info = {
|
klass_info = {
|
||||||
'model': model,
|
'model': model,
|
||||||
'field': f,
|
'field': f,
|
||||||
|
@ -102,12 +102,3 @@ class Child3(Child2):
|
|||||||
|
|
||||||
class Child4(Child1):
|
class Child4(Child1):
|
||||||
value4 = models.IntegerField()
|
value4 = models.IntegerField()
|
||||||
|
|
||||||
|
|
||||||
class LinkedList(models.Model):
|
|
||||||
name = models.CharField(max_length=50)
|
|
||||||
previous_item = models.OneToOneField(
|
|
||||||
'self', models.CASCADE,
|
|
||||||
related_name="next_item", blank=True,
|
|
||||||
null=True,
|
|
||||||
)
|
|
||||||
|
@ -6,9 +6,8 @@ from django.core.exceptions import FieldError
|
|||||||
from django.test import TestCase
|
from django.test import TestCase
|
||||||
|
|
||||||
from .models import (
|
from .models import (
|
||||||
AdvancedUserStat, Child1, Child2, Child3, Child4, Image, LinkedList,
|
AdvancedUserStat, Child1, Child2, Child3, Child4, Image, Parent1, Parent2,
|
||||||
Parent1, Parent2, Product, StatDetails, User, UserProfile, UserStat,
|
Product, StatDetails, User, UserProfile, UserStat, UserStatResult,
|
||||||
UserStatResult,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@ -213,13 +212,6 @@ class ReverseSelectRelatedTestCase(TestCase):
|
|||||||
with self.assertNumQueries(1):
|
with self.assertNumQueries(1):
|
||||||
self.assertEqual(p.child1.child4.name1, 'n1')
|
self.assertEqual(p.child1.child4.name1, 'n1')
|
||||||
|
|
||||||
def test_self_relation(self):
|
|
||||||
item1 = LinkedList.objects.create(name='item1')
|
|
||||||
LinkedList.objects.create(name='item2', previous_item=item1)
|
|
||||||
with self.assertNumQueries(1):
|
|
||||||
item1_db = LinkedList.objects.select_related('next_item').get(name='item1')
|
|
||||||
self.assertEqual(item1_db.next_item.name, 'item2')
|
|
||||||
|
|
||||||
|
|
||||||
class ReverseSelectRelatedValidationTests(TestCase):
|
class ReverseSelectRelatedValidationTests(TestCase):
|
||||||
"""
|
"""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user