(id: UUID4, db_session: DatabaseDependency, atleta_up: AtletaUpdate = Body(...))
| 102 | response_model=AtletaOut, |
| 103 | ) |
| 104 | async def patch(id: UUID4, db_session: DatabaseDependency, atleta_up: AtletaUpdate = Body(...)) -> AtletaOut: |
| 105 | atleta: AtletaOut = ( |
| 106 | await db_session.execute(select(AtletaModel).filter_by(id=id)) |
| 107 | ).scalars().first() |
| 108 | |
| 109 | if not atleta: |
| 110 | raise HTTPException( |
| 111 | status_code=status.HTTP_404_NOT_FOUND, |
| 112 | detail=f'Atleta não encontrado no id: {id}' |
| 113 | ) |
| 114 | |
| 115 | atleta_update = atleta_up.model_dump(exclude_unset=True) |
| 116 | for key, value in atleta_update.items(): |
| 117 | setattr(atleta, key, value) |
| 118 | |
| 119 | await db_session.commit() |
| 120 | await db_session.refresh(atleta) |
| 121 | |
| 122 | return atleta |
| 123 | |
| 124 | |
| 125 | @router.delete( |
nothing calls this directly
no outgoing calls
no test coverage detected