Fixed syntax misc issues
This commit is contained in:
parent
c07423f8b0
commit
9cc09014a4
3 changed files with 33 additions and 14 deletions
|
|
@ -1,3 +1,5 @@
|
|||
from sqlmodel import inspect
|
||||
|
||||
from app.database import (
|
||||
add_to_database,
|
||||
delete_from_database_where,
|
||||
|
|
@ -26,11 +28,16 @@ def update(
|
|||
update_attribute: str,
|
||||
new_value: int | str | None,
|
||||
):
|
||||
if update_attribute not in inspect(Service).attrs:
|
||||
raise ValueError(f"Invalid attribute: {update_attribute}")
|
||||
|
||||
attribute = getattr(Service, update_attribute)
|
||||
|
||||
return update_database_where(
|
||||
Service,
|
||||
Service.id,
|
||||
Service.id, # type: ignore (Type correct on runtime)
|
||||
service_id,
|
||||
update_attribute,
|
||||
attribute,
|
||||
new_value,
|
||||
)
|
||||
|
||||
|
|
@ -38,6 +45,6 @@ def update(
|
|||
def delete(service_id: int):
|
||||
return delete_from_database_where(
|
||||
Service,
|
||||
Service.id,
|
||||
Service.id, # type: ignore (Type correct on runtime)
|
||||
service_id,
|
||||
)
|
||||
|
|
|
|||
Loading…
Reference in a new issue