From ca545b72b90ae555f571afe122b4d37bfbced98a Mon Sep 17 00:00:00 2001 From: Donkie Date: Mon, 20 May 2024 22:42:44 +0200 Subject: [PATCH] Fixed spool price sorting not working Resolves #349 --- spoolman/database/spool.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/spoolman/database/spool.py b/spoolman/database/spool.py index 2192b720c..08a2b421e 100644 --- a/spoolman/database/spool.py +++ b/spoolman/database/spool.py @@ -109,7 +109,7 @@ async def get_by_id(db: AsyncSession, spool_id: int) -> models.Spool: return spool -async def find( # noqa: C901 +async def find( # noqa: C901, PLR0912 *, db: AsyncSession, filament_name: Optional[str] = None, @@ -185,6 +185,8 @@ async def find( # noqa: C901 elif fieldstr == "filament.combined_name": sorts.append(models.Vendor.name) sorts.append(models.Filament.name) + elif fieldstr == "price": + sorts.append(coalesce(models.Spool.price, models.Filament.price)) else: sorts.append(parse_nested_field(models.Spool, fieldstr))