(hero_id: int, hero: HeroUpdate)
| 73 | |
| 74 | @app.patch("/heroes/{hero_id}", response_model=HeroPublic) |
| 75 | def update_hero(hero_id: int, hero: HeroUpdate): |
| 76 | with Session(engine) as session: |
| 77 | db_hero = session.get(Hero, hero_id) |
| 78 | if not db_hero: |
| 79 | raise HTTPException(status_code=404, detail="Hero not found") |
| 80 | hero_data = hero.model_dump(exclude_unset=True) |
| 81 | db_hero.sqlmodel_update(hero_data) |
| 82 | session.add(db_hero) |
| 83 | session.commit() |
| 84 | session.refresh(db_hero) |
| 85 | return db_hero |
nothing calls this directly
no test coverage detected
searching dependent graphs…