mirror of
https://github.com/maziggy/bambuddy.git
synced 2026-10-17 19:36:28 +02:00
Fix 500 error on GET /archives/{id} endpoint
Load project relationship in ArchiveService.get_archive() alongside created_by. Async SQLAlchemy doesn't support lazy loading, so project must be eagerly loaded for archive_to_response() to access project.name.
This commit is contained in:
@@ -47,6 +47,10 @@ All notable changes to Bambuddy will be documented in this file.
|
||||
- Placeholder text shows expected format (e.g., "DD/MM/YYYY" or "HH:MM AM/PM")
|
||||
- Added date utilities: `formatDateInput`, `parseDateInput`, `getDatePlaceholder`
|
||||
- Added time utilities: `formatTimeInput`, `parseTimeInput`, `getTimePlaceholder`
|
||||
- **500 Error on Archive Detail Page**:
|
||||
- Fixed internal server error when viewing individual archive details
|
||||
- Root cause: `project` relationship not eagerly loaded in `get_archive()` service method
|
||||
- Async SQLAlchemy requires explicit eager loading; lazy loading is not supported
|
||||
|
||||
## [0.1.6.2] - 2026-02-02
|
||||
|
||||
|
||||
@@ -933,11 +933,13 @@ class ArchiveService:
|
||||
return archive
|
||||
|
||||
async def get_archive(self, archive_id: int) -> PrintArchive | None:
|
||||
"""Get an archive by ID with creator loaded."""
|
||||
"""Get an archive by ID with relationships loaded."""
|
||||
from sqlalchemy.orm import selectinload
|
||||
|
||||
result = await self.db.execute(
|
||||
select(PrintArchive).options(selectinload(PrintArchive.created_by)).where(PrintArchive.id == archive_id)
|
||||
select(PrintArchive)
|
||||
.options(selectinload(PrintArchive.created_by), selectinload(PrintArchive.project))
|
||||
.where(PrintArchive.id == archive_id)
|
||||
)
|
||||
return result.scalar_one_or_none()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user