Adjusted files for isort & autopep

This commit is contained in:
creyD
2025-04-03 07:45:38 +00:00
committed by github-actions[bot]
parent 910638e3a6
commit c903266ec4

View File

@@ -53,24 +53,22 @@ def get_object_or_404(
query = select(*selected_columns).where(getattr(db_class, lookup_column) == id)
result = await db.execute(query)
row = result.first()
if row is None:
raise HTTPException(status_code=404, detail="The object does not exist.")
if hasattr(row, "_mapping"):
obj_dict = dict(row._mapping)
else:
obj_dict = {column.key: getattr(row, column.key)
for column in selected_columns}
obj_dict = {column.key: getattr(row, column.key) for column in selected_columns}
else:
query = select(db_class).where(getattr(db_class, lookup_column) == id)
result = await db.execute(query)
row = result.scalar_one_or_none()
if row is None:
raise HTTPException(status_code=404, detail="The object does not exist.")
obj_dict = {k: v for k, v in row.__dict__.items()
if not k.startswith('_')}
obj_dict = {k: v for k, v in row.__dict__.items() if not k.startswith("_")}
if expunge:
await db.expunge(obj_dict)
return obj_dict