Compare commits

...

1 Commits
1.2.0 ... 1.2.1

Author SHA1 Message Date
f24db62781 fix: fixed a bug with the jsonschema for order_by 2024-04-25 18:44:58 +02:00
2 changed files with 4 additions and 3 deletions

View File

@@ -36,7 +36,7 @@ def update_obj_from_data(
model: Type[T], model: Type[T],
id: UUID | str, id: UUID | str,
db: Session, db: Session,
partial: bool = False, partial: bool = False, # TODO: inverse, because it is currently the wrong way around
ignore_fields=[], ignore_fields=[],
additional_data={}, additional_data={},
exclude={}, 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 import asc, desc
from sqlalchemy.sql.selectable import Select 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: def _order_by(query: Select) -> Select:
if order_by: if order_by:
direction = desc if order_by.startswith("-") else asc direction = desc if order_by.startswith("-") else asc