Wrap transformation cloning in a transaction.

This commit is contained in:
Roberto Rosario
2015-07-15 01:01:58 -04:00
parent 1b37a13bf5
commit da0e03bf12

View File

@@ -5,7 +5,7 @@ import logging
import yaml
from django.contrib.contenttypes.models import ContentType
from django.db import models
from django.db import models, transaction
from .classes import BaseTransformation
@@ -38,9 +38,10 @@ class TransformationManager(models.Manager):
logger.debug('results: %s', results)
# Bulk create for a single DB query
self.bulk_create(
map(lambda entry: self.model(**entry), results),
)
with transaction.atomic():
self.bulk_create(
map(lambda entry: self.model(**entry), results),
)
def get_for_model(self, obj, as_classes=False):
"""