Ticket #13906: 13906_get_or_create.diff

File 13906_get_or_create.diff, 876 bytes (added by Ian Clelland, 13 years ago)

Reordering reads in get_or_create

  • django/db/models/query.py

     
    367367                lookup[f.name] = lookup.pop(f.attname)
    368368        try:
    369369            self._for_write = True
     370            sid = transaction.savepoint(using=self.db)
    370371            return self.get(**lookup), False
    371372        except self.model.DoesNotExist:
    372373            try:
    373374                params = dict([(k, v) for k, v in kwargs.items() if '__' not in k])
    374375                params.update(defaults)
    375376                obj = self.model(**params)
    376                 sid = transaction.savepoint(using=self.db)
    377377                obj.save(force_insert=True, using=self.db)
    378378                transaction.savepoint_commit(sid, using=self.db)
    379379                return obj, True
Back to Top