diff options
| author | Simon Charette <charette.s@gmail.com> | 2019-12-11 22:34:28 -0500 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2019-12-30 08:30:44 +0100 |
| commit | 7db4ab84394f5ffa588d5d968f6b76178740fb51 (patch) | |
| tree | 7205b47b298f0bcf8b1a967bc3c8434bc3f78d8f /django/db | |
| parent | 0f8041abd5bf0977d28b676445d35a81c6b7b5de (diff) | |
[3.0.x] Fixed #31071 -- Disabled insert optimization for primary keys with defaults when loading fixtures.
Model.save_base() is called directly when loading fixtures and assumes
existing rows will be updated. Branching of "raw" allows to maintain
the optimization introduced in #29260 while supporting this edge case.
Regression in 85458e94e38c20e57939947ee515a1a53689659f.
Thanks Reupen Shah for the report.
Backport of 5779cc938a34eb96815c7a40ded2c8f6c8087c58 from master
Diffstat (limited to 'django/db')
| -rw-r--r-- | django/db/models/base.py | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/django/db/models/base.py b/django/db/models/base.py index 0b8425aa85..3552dc5783 100644 --- a/django/db/models/base.py +++ b/django/db/models/base.py @@ -848,6 +848,7 @@ class Model(metaclass=ModelBase): updated = False # Skip an UPDATE when adding an instance and primary key has a default. if ( + not raw and not force_insert and self._state.adding and self._meta.pk.default and |
