Skip to content

Commit eeab63e

Browse files
authored
Refs #26552 -- Made reloading the database for tests check only loaded tables constraints.
1 parent 4c98860 commit eeab63e

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

django/db/backends/base/creation.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,16 +127,18 @@ def deserialize_db_from_string(self, data):
127127
the serialize_db_to_string() method.
128128
"""
129129
data = StringIO(data)
130+
table_names = set()
130131
# Load data in a transaction to handle forward references and cycles.
131132
with atomic(using=self.connection.alias):
132133
# Disable constraint checks, because some databases (MySQL) doesn't
133134
# support deferred checks.
134135
with self.connection.constraint_checks_disabled():
135136
for obj in serializers.deserialize('json', data, using=self.connection.alias):
136137
obj.save()
138+
table_names.add(obj.object.__class__._meta.db_table)
137139
# Manually check for any invalid keys that might have been added,
138140
# because constraint checks were disabled.
139-
self.connection.check_constraints()
141+
self.connection.check_constraints(table_names=table_names)
140142

141143
def _get_database_display_str(self, verbosity, database_name):
142144
"""

0 commit comments

Comments
 (0)