change order in save_related -> first upsert self then follow
This commit is contained in:
@ -191,6 +191,9 @@ class Model(ModelRow):
|
|||||||
value = [value]
|
value = [value]
|
||||||
|
|
||||||
for val in value:
|
for val in value:
|
||||||
|
if not val.saved or save_all:
|
||||||
|
await val.upsert()
|
||||||
|
update_count += 1
|
||||||
if follow:
|
if follow:
|
||||||
update_count = await val.save_related(
|
update_count = await val.save_related(
|
||||||
follow=follow,
|
follow=follow,
|
||||||
@ -198,9 +201,6 @@ class Model(ModelRow):
|
|||||||
relation_map=relation_map,
|
relation_map=relation_map,
|
||||||
update_count=update_count,
|
update_count=update_count,
|
||||||
)
|
)
|
||||||
if not val.saved or save_all:
|
|
||||||
await val.upsert()
|
|
||||||
update_count += 1
|
|
||||||
return update_count
|
return update_count
|
||||||
|
|
||||||
async def update(self: T, **kwargs: Any) -> T:
|
async def update(self: T, **kwargs: Any) -> T:
|
||||||
|
|||||||
@ -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()
|
||||||
Reference in New Issue
Block a user