fix: fixed a bug with the jsonschema for order_by

This commit is contained in:
2024-04-25 18:44:58 +02:00
parent 4d997a375e
commit f24db62781
2 changed files with 4 additions and 3 deletions

View File

@@ -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={},

View File

@@ -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