Added tests for spool find sorting
This commit is contained in:
@@ -159,7 +159,7 @@ async def find(
|
||||
description=(
|
||||
'Sort the results by the given field. Should be a comma-separate string with "field:direction" items.'
|
||||
),
|
||||
example="filament.name:asc,vendor.id:asc,location:desc",
|
||||
example="filament.name:asc,filament.vendor.id:asc,location:desc",
|
||||
),
|
||||
limit: Optional[int] = Query(
|
||||
default=None,
|
||||
|
||||
@@ -19,7 +19,7 @@ def parse_nested_field(base_obj: type[models.Base], field: str) -> attributes.In
|
||||
"""Parse a nested field string into a sqlalchemy field object."""
|
||||
fields = field.split(".")
|
||||
if not hasattr(base_obj, fields[0]):
|
||||
raise ValueError(f"Invalid field name '{field}'")
|
||||
raise ValueError(f"Invalid field name '{field}', '{fields[0]}' is not a valid field on '{base_obj.__name__}'.")
|
||||
|
||||
if fields[0] == "filament" and len(fields) == 1:
|
||||
raise ValueError("No field specified for filament")
|
||||
|
||||
Reference in New Issue
Block a user