From f24db62781ef75419892e1e69d7af81e3f6bc8ce Mon Sep 17 00:00:00 2001 From: Conrad Date: Thu, 25 Apr 2024 18:44:58 +0200 Subject: [PATCH] fix: fixed a bug with the jsonschema for order_by --- creyPY/fastapi/crud.py | 2 +- creyPY/fastapi/order_by.py | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/creyPY/fastapi/crud.py b/creyPY/fastapi/crud.py index 5e039c1..63ec901 100644 --- a/creyPY/fastapi/crud.py +++ b/creyPY/fastapi/crud.py @@ -36,7 +36,7 @@ def update_obj_from_data( model: Type[T], id: UUID | str, db: Session, - partial: bool = False, + partial: bool = False, # TODO: inverse, because it is currently the wrong way around ignore_fields=[], additional_data={}, exclude={}, diff --git a/creyPY/fastapi/order_by.py b/creyPY/fastapi/order_by.py index 7c85dff..3238893 100644 --- a/creyPY/fastapi/order_by.py +++ b/creyPY/fastapi/order_by.py @@ -1,10 +1,11 @@ -from typing import Callable, Optional +from typing import Callable +from pydantic.json_schema import SkipJsonSchema from sqlalchemy import asc, desc from sqlalchemy.sql.selectable import Select -def order_by(order_by: Optional[str] = None) -> Callable[[Select], Select]: +def order_by(order_by: str | SkipJsonSchema[None] = None) -> Callable[[Select], Select]: def _order_by(query: Select) -> Select: if order_by: direction = desc if order_by.startswith("-") else asc