Skip to content
This repository was archived by the owner on Sep 19, 2024. It is now read-only.

Commit 8de0254

Browse files
authored
Merge pull request #11 from bemble/fix_delete_download
fix(server): fix get model
2 parents 41407a8 + 284317d commit 8de0254

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

server/holerr/api/routers/downloads.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ async def list_downloads():
1717
@router.delete("/{download_id}", response_model=Download, tags=["Downloads"])
1818
async def delete_download(download_id: str):
1919
session = db.new_session()
20-
download = DownloadRepository(session).get_model(download_id)
20+
download = DownloadRepository(session).get_model(download_id.encode('UTF-8'))
2121
if download is None:
2222
raise HTTPException(status_code=404, detail=f"Download {download_id} not found")
2323
download.to_delete = True

server/holerr/database/repositories.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ def __init__(self, session: Session, entity: Base):
2424
self.entity = entity
2525

2626
def get_model(self, id: any) -> Base | None:
27-
res = self.session.scalars(select(self.entity).where(self.entity.id == id))
28-
return res.one_or_none()
27+
res = self.get_all_models(self.entity.id == id)
28+
return res[0] if len(res) > 0 else None
2929

3030
def get_all_models(self, conditions=True, options=None) -> list[Base]:
3131
query = select(self.entity).where(conditions)

0 commit comments

Comments
 (0)