mirror of
https://github.com/django/django.git
synced 2025-10-24 14:16:09 +00:00
Refs #31051 -- Fixed reloading the database with circular related objects and natural keys for tests.
Made deserialize_db_from_string() do not sort dependencies. deserialize_db_from_string() doesn't use natural keys, so there is no need to sort dependencies in serialize_db_to_string(). Moreover, sorting models cause issues for circular dependencies.
This commit is contained in:
committed by
Mariusz Felisiak
parent
12e6f573ad
commit
289d0ec6fd
@@ -107,6 +107,22 @@ class ObjectSelfReference(models.Model):
|
||||
obj = models.ForeignKey('ObjectSelfReference', models.SET_NULL, null=True)
|
||||
|
||||
|
||||
class CircularA(models.Model):
|
||||
key = models.CharField(max_length=3, unique=True)
|
||||
obj = models.ForeignKey('CircularB', models.SET_NULL, null=True)
|
||||
|
||||
def natural_key(self):
|
||||
return (self.key,)
|
||||
|
||||
|
||||
class CircularB(models.Model):
|
||||
key = models.CharField(max_length=3, unique=True)
|
||||
obj = models.ForeignKey('CircularA', models.SET_NULL, null=True)
|
||||
|
||||
def natural_key(self):
|
||||
return (self.key,)
|
||||
|
||||
|
||||
class RawData(models.Model):
|
||||
raw_data = models.BinaryField()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user