fix support for lazy init for db.update
This commit is contained in:
parent
3f9cec3e79
commit
b0832b8659
1 changed files with 4 additions and 0 deletions
|
|
@ -225,6 +225,10 @@ async def get_all(model: Type[ModelType], **kwds) -> Iterable[ModelType]:
|
|||
|
||||
|
||||
async def update(item):
|
||||
# Support late initializing - used for optimization.
|
||||
if getattr(item, "_is_lazy", False):
|
||||
item._lazy_init()
|
||||
|
||||
values = asplain(item)
|
||||
keys = ", ".join(f"{k}=:{k}" for k in values if k != "id")
|
||||
query = f"UPDATE {item._table} SET {keys} WHERE id=:id"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue