Do not restore values for created records when exception is raised when saving
Once a record has been created, the id is modified which change its hash value such that it can not be found anymore. But as the creation succeeded (and only the write part has failed) we can just restore the values to None. Closes #14093
This commit is contained in:
1 parent
125668e0e2
commit
dbb65081b0
1 file changed
+2
-2
@@ -2199,8 +2199,8 @@ class ModelStorage(Model):
|
||||
cls.write(*sum(
|
||||
(([r], save_values[r]) for r in to_write), ()))
|
||||
except Exception:
|
||||
for record in to_create + to_write:
|
||||
record._values = values[record]
|
||||
for record in chain(to_create, to_write):
|
||||
record._values = values.get(record)
|
||||
raise
|
||||
for record in to_create + to_write:
|
||||
record._init_values = None
|
||||
|
||||
Reference in new issue
Block a user