Skip to content

Commit

Permalink
changed base crud, fixed pylint
Browse files Browse the repository at this point in the history
  • Loading branch information
zimaexe committed Mar 5, 2025
1 parent 9a9a081 commit 12397c0
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 32 deletions.

This file was deleted.

3 changes: 2 additions & 1 deletion margin_app/app/api/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ async def create_user(user: UserCreate)-> UserResponse:
user_db = await user_crud.get_object_by_field(field="wallet_id", value=user.wallet_id)

if user_db:
raise HTTPException(status_code=status.HTTP_400_BAD_REQUEST, detail="User with such wallet_id laready exist.")
raise HTTPException(status_code=status.HTTP_400_BAD_REQUEST,
detail="User with such wallet_id laready exist.")

try:
user = await user_crud.create_user(user.wallet_id)
Expand Down
2 changes: 1 addition & 1 deletion margin_app/app/crud/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ async def get_object_by_field(
"""
async with self.session() as db:
result = await db.execute(select(model).where(getattr(model, field) == value))
return result.scalar_one()
return result.scalar_one_or_none()

async def delete_object_by_id(
self, model: Type[ModelType] = None, obj_id: uuid = None
Expand Down

0 comments on commit 12397c0

Please sign in to comment.