mirror of
https://github.com/django/django.git
synced 2025-10-29 00:26:07 +00:00
Changed create() and get_or_create() to force an insert (not update an existing value).
Backwards incompatible if you are using manually-specific primary key values and relying on the previously documented behaviour that the new values would always exist in the database (i.e. it would update the existing entry). Fixed #8419. git-svn-id: http://code.djangoproject.com/svn/django/trunk@8670 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
@@ -308,7 +308,7 @@ class QuerySet(object):
|
||||
and returning the created object.
|
||||
"""
|
||||
obj = self.model(**kwargs)
|
||||
obj.save()
|
||||
obj.save(force_insert=True)
|
||||
return obj
|
||||
|
||||
def get_or_create(self, **kwargs):
|
||||
@@ -328,7 +328,7 @@ class QuerySet(object):
|
||||
params.update(defaults)
|
||||
obj = self.model(**params)
|
||||
sid = transaction.savepoint()
|
||||
obj.save()
|
||||
obj.save(force_insert=True)
|
||||
transaction.savepoint_commit(sid)
|
||||
return obj, True
|
||||
except IntegrityError, e:
|
||||
|
||||
Reference in New Issue
Block a user