Fixed spools with unset archive state being hidden

This commit is contained in:
Donkie
2023-07-14 19:04:54 +02:00
parent 3bc47cc686
commit d14fce013c

View File

@@ -109,7 +109,13 @@ async def find(
if lot_nr is not None: if lot_nr is not None:
stmt = stmt.where(models.Spool.lot_nr.ilike(f"%{lot_nr}%")) stmt = stmt.where(models.Spool.lot_nr.ilike(f"%{lot_nr}%"))
if not allow_archived: if not allow_archived:
stmt = stmt.where(models.Spool.archived != True) # noqa: E712 # Since the archived field is nullable, and default is false, we need to check for both false or null
stmt = stmt.where(
sqlalchemy.or_(
models.Spool.archived.is_(False), # noqa: FBT003
models.Spool.archived.is_(None),
),
)
rows = await db.execute(stmt) rows = await db.execute(stmt)
return list(rows.scalars().all()) return list(rows.scalars().all())