diff --git a/margin_app/app/alembic/versions/2025-03-05_added_lazy_selection_for_user_and_.py b/margin_app/app/alembic/versions/2025-03-05_added_lazy_selection_for_user_and_.py deleted file mode 100644 index 9811a4b4..00000000 --- a/margin_app/app/alembic/versions/2025-03-05_added_lazy_selection_for_user_and_.py +++ /dev/null @@ -1,30 +0,0 @@ -"""added lazy selection for user and deposits - -Revision ID: 04844aee175f -Revises: fe041c2f01ee -Create Date: 2025-03-05 19:14:50.050535 - -""" -from typing import Sequence, Union - -from alembic import op -import sqlalchemy as sa - - -# revision identifiers, used by Alembic. -revision: str = '04844aee175f' -down_revision: Union[str, None] = 'fe041c2f01ee' -branch_labels: Union[str, Sequence[str], None] = None -depends_on: Union[str, Sequence[str], None] = None - - -def upgrade() -> None: - # ### commands auto generated by Alembic - please adjust! ### - pass - # ### end Alembic commands ### - - -def downgrade() -> None: - # ### commands auto generated by Alembic - please adjust! ### - pass - # ### end Alembic commands ### diff --git a/margin_app/app/api/user.py b/margin_app/app/api/user.py index 5f1c3565..5b0e358b 100644 --- a/margin_app/app/api/user.py +++ b/margin_app/app/api/user.py @@ -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) diff --git a/margin_app/app/crud/base.py b/margin_app/app/crud/base.py index 8cb4fa92..a1fd2ed9 100644 --- a/margin_app/app/crud/base.py +++ b/margin_app/app/crud/base.py @@ -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