diff options
| author | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2020-04-17 08:14:27 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-04-17 08:14:27 +0200 |
| commit | eeab63e57e797c41fa42ffe804927c5f77a0d739 (patch) | |
| tree | b805526bf74cbd7facc4a2c5e37d45375c08ad58 | |
| parent | 4c9886085b774520660844e11d682e194d622df6 (diff) | |
Refs #26552 -- Made reloading the database for tests check only loaded tables constraints.
| -rw-r--r-- | django/db/backends/base/creation.py | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/django/db/backends/base/creation.py b/django/db/backends/base/creation.py index 55aca5fdb2..503f7f56fd 100644 --- a/django/db/backends/base/creation.py +++ b/django/db/backends/base/creation.py @@ -127,6 +127,7 @@ class BaseDatabaseCreation: the serialize_db_to_string() method. """ data = StringIO(data) + table_names = set() # Load data in a transaction to handle forward references and cycles. with atomic(using=self.connection.alias): # Disable constraint checks, because some databases (MySQL) doesn't @@ -134,9 +135,10 @@ class BaseDatabaseCreation: with self.connection.constraint_checks_disabled(): for obj in serializers.deserialize('json', data, using=self.connection.alias): obj.save() + table_names.add(obj.object.__class__._meta.db_table) # Manually check for any invalid keys that might have been added, # because constraint checks were disabled. - self.connection.check_constraints() + self.connection.check_constraints(table_names=table_names) def _get_database_display_str(self, verbosity, database_name): """ |
