mirror of
https://github.com/django/django.git
synced 2025-11-25 05:04:26 +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:
parent
12e6f573ad
commit
289d0ec6fd
3 changed files with 46 additions and 5 deletions
|
|
@ -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()
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue