wip
This commit is contained in:
@@ -9,14 +9,14 @@ def make_primary_annotation(name=str):
|
||||
return Annotated[str, Path(description=f'{name}, either id (int) or code')]
|
||||
|
||||
|
||||
def get_single_record(session, cls, code: str):
|
||||
def get_single_record(session, cls, name: str, code: str):
|
||||
result = session.get(cls, code)
|
||||
if result is None:
|
||||
result = session.scalar(select(cls).where(cls.code == code))
|
||||
if result is None:
|
||||
raise HTTPException(
|
||||
status_code=404,
|
||||
detail=f"{cls.__class__.__name__} {code!r} not found.")
|
||||
detail=f"{name} {code!r} not found.")
|
||||
return result
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user