Closed yezyilomo closed 2 years ago
Hey, thanks for the fix. One question: Won't saving the instance in a for loop cause unnecessary queries? Wouldn't it be better to first set the values and then save the instance only once? Or are there some other reasons for this?
I thought about that too but the thing is instance.save
should be called only when nested_obj
is None
which is not always the case when update_writable_foreignkey_related
is called, so we'll still have unnecessary queries.
@sommelon But I guess you could argue that the number of unnecessary queries we would have if we run instance.save
outside the loop would be smaller than running inside the loop.
I see what you mean. Maybe there could be a flag like needs_save
or something that could be set when necessary and later decide whether to save or not.
Having a flag seems great, though it will be executing repeatedly in a loop, but I don't think it will be as expensive as executing an unnecessary query, so let's settle for this for now.
@yezyilomo great, thanks for the release!
@yezyilomo great, thanks for the release!
You’re welcome