Skip to content

Commit

Permalink
fix: make get_or_none compatible with lower version
Browse files Browse the repository at this point in the history
  • Loading branch information
NightMarcher committed Nov 11, 2022
1 parent 51ba671 commit ff5abde
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion examples/service/routers/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ async def create_view():
async def update_view(
aid: int = Query(...),
):
account = await AccountMgr.get_by_pk(aid)
account = await AccountMgr.get_by_pk(pk=aid, conn=AccountMgr.rw_conn)
if not account:
return {"found": False, "ok": False}

Expand Down
2 changes: 1 addition & 1 deletion fastapi_esql/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
timing,
)

__version__ = "0.0.2"
__version__ = "0.0.3"

__all__ = [
"QsParsingError",
Expand Down
4 changes: 2 additions & 2 deletions fastapi_esql/orm/base_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@

class BaseManager(metaclass=AppMetaclass):

model = Model
model: Model = Model

@classmethod
async def get_by_pk(
cls,
pk: Any,
conn: Optional[BaseDBAsyncClient] = None,
) -> Optional[Model]:
return await cls.model.get_or_none(pk=pk, using_db=conn)
return await cls.model.get_or_none(pk=pk).using_db(conn)

@classmethod
async def create_from_dict(cls, params: Dict[str, Any]) -> Optional[Model]:
Expand Down

0 comments on commit ff5abde

Please sign in to comment.