add saving status and basic test for this

This commit is contained in:
collerek
2020-11-13 13:39:19 +01:00
parent 381995250d
commit b0cf916531
5 changed files with 300 additions and 52 deletions

View File

@ -358,8 +358,10 @@ class QuerySet:
instance.pk = pk
# refresh server side defaults
instance = await instance.load()
if any(field.server_default is not None
for name, field in self.model.Meta.model_fields.items() if name not in kwargs):
instance = await instance.load()
instance.set_save_status(True)
return instance
async def bulk_create(self, objects: List["Model"]) -> None:
@ -372,6 +374,9 @@ class QuerySet:
expr = self.table.insert()
await self.database.execute_many(expr, ready_objects)
for objt in objects:
objt.set_save_status(True)
async def bulk_update(
self, objects: List["Model"], columns: List[str] = None
) -> None:
@ -418,3 +423,6 @@ class QuerySet:
# otherwise it just passes all data to values and results in unconsumed columns
expr = str(expr)
await self.database.execute_many(expr, ready_objects)
for objt in objects:
objt.set_save_status(True)