1
0
mirror of https://github.com/django/django.git synced 2025-10-31 09:41:08 +00:00

Fixed #33582 -- Fixed deserializing natural keys with foreing key dependencies in a multiple database setup.

This commit is contained in:
François Granade
2022-03-18 11:17:54 +01:00
committed by Mariusz Felisiak
parent ed6db53542
commit 4b8e4f5060
4 changed files with 58 additions and 1 deletions

View File

@@ -44,6 +44,7 @@ from .models import (
M2MSimpleCircularA,
M2MSimpleCircularB,
M2MThroughAB,
NaturalKeyWithFKDependency,
NKChild,
Parent,
Person,
@@ -791,6 +792,25 @@ class NaturalKeyFixtureTests(TestCase):
)
class NaturalKeyFixtureOnOtherDatabaseTests(TestCase):
databases = {"other"}
def test_natural_key_dependencies(self):
"""
Natural keys with foreing keys in dependencies works in a multiple
database setup.
"""
management.call_command(
"loaddata",
"nk_with_foreign_key.json",
database="other",
verbosity=0,
)
obj = NaturalKeyWithFKDependency.objects.using("other").get()
self.assertEqual(obj.name, "The Lord of the Rings")
self.assertEqual(obj.author.name, "J.R.R. Tolkien")
class M2MNaturalKeyFixtureTests(TestCase):
"""Tests for ticket #14426."""