mirror of
https://github.com/django/django.git
synced 2025-09-26 12:09:19 +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:
parent
79348d4018
commit
c181734fa1
3 changed files with 25 additions and 5 deletions
|
@ -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:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue