refactor kontor-api to use SQLAlchemy 2.0 features for mapping fields

(cherry picked from commit e57abdbef7e13e3880738cd639225df5db0c37be)
This commit is contained in:
Thomas Peetz
2026-01-29 14:43:37 +01:00
parent 25fa07d517
commit cf770f4814
20 changed files with 364 additions and 685 deletions
@@ -36,11 +36,12 @@ def get_artist_details(artist: Artist) -> ArtistDetailResponse:
)
return response
def update_artist(add_artist: AddArtist, artist_id: str, db: Session) -> Artist:
def update_artist(add_artist: AddArtist, artist_id: str, db: Session) -> Optional[Artist]:
logger.info("update artist")
artist: Optional[Artist] = db.get(Artist, artist_id)
artist.name = add_artist.name
db.add(artist)
db.commit()
db.refresh(artist)
if artist is not None:
artist.name = add_artist.name
db.add(artist)
db.commit()
db.refresh(artist)
return artist