exclude pk_only models from beeing save_related

This commit is contained in:
collerek
2021-03-30 17:54:28 +02:00
parent 04047e4cd9
commit 4dc11b0de4
2 changed files with 2 additions and 2 deletions

View File

@ -191,7 +191,7 @@ class Model(ModelRow):
value = [value] value = [value]
for val in value: for val in value:
if not val.saved or save_all: if (not val.saved or save_all) and not val.__pk_only__:
await val.upsert() await val.upsert()
update_count += 1 update_count += 1
if follow: if follow:

View File

@ -155,4 +155,4 @@ def create_test_database():
async def test_saving_related_fk_rel(): async def test_saving_related_fk_rel():
async with database: async with database:
async with database.transaction(force_rollback=True): async with database.transaction(force_rollback=True):
await Report.objects.select_all(follow=True).all() await Report.objects.select_all(follow=True).all()