Fixed syntax misc issues

This commit is contained in:
Hannah dagemark 2026-08-10 23:11:21 +02:00
commit 9cc09014a4
3 changed files with 33 additions and 14 deletions

View file

@ -1,3 +1,5 @@
from sqlmodel import inspect
from app.database import (
add_to_database,
delete_from_database_where,
@ -17,10 +19,10 @@ def get_by_id(project_id: int):
return get_from_database_where_id(Project, project_id)
def get_with_parent(project_id: int):
def get_with_parent(project_id: int | None):
return get_from_database_where(
Project,
Project.parent_id,
Project.id, # type: ignore (Type correct on runtime)
project_id,
)
@ -35,11 +37,16 @@ def update(
update_attribute: str,
new_value: int | str | None,
):
if update_attribute not in inspect(Project).attrs:
raise ValueError(f"Invalid attribute: {update_attribute}")
attribute = getattr(Project, update_attribute)
return update_database_where(
Project,
Project.id,
Project.id, # type: ignore (Type correct on runtime)
project_id,
update_attribute,
attribute,
new_value,
)
@ -47,6 +54,6 @@ def update(
def delete(project_id: int):
return delete_from_database_where(
Project,
Project.id,
Project.id, # type: ignore (Type correct on runtime)
project_id,
)