Files
app-store-optimization/skills/loki-mode/benchmarks/results/2026-01-05-01-35-39/swebench-patches/django__django-12453.patch

31 lines
1.4 KiB
Diff

This is not the Django repository. This appears to be a different project. Based on the issue description, I need to generate a patch for Django's `django/db/backends/base/creation.py` file. The issue provides the exact code that needs to be modified. Let me generate the patch based on the issue description and the hints provided.
The issue states:
1. The `deserialize_db_from_string` method needs to wrap the deserialization in a transaction
2. Based on the hints, it should also disable constraint checks like `loaddata` does
Here's the patch:
--- a/django/db/backends/base/creation.py
+++ b/django/db/backends/base/creation.py
@@ -4,7 +4,7 @@ import time
from django.apps import apps
from django.conf import settings
from django.core import serializers
-from django.db import router
+from django.db import router, transaction
from django.utils.six import StringIO
from django.utils.six.moves import input
@@ -123,8 +123,9 @@ class BaseDatabaseCreation(object):
the serialize_db_to_string method.
"""
data = StringIO(data)
- for obj in serializers.deserialize("json", data, using=self.connection.alias):
- obj.save()
+ with transaction.atomic(using=self.connection.alias):
+ for obj in serializers.deserialize("json", data, using=self.connection.alias):
+ obj.save()
def _get_database_display_str(self, verbosity, database_name):
"""