Added database support for finding empty fields

This commit is contained in:
Donkie
2023-09-07 21:50:12 +02:00
parent f62f9d899b
commit de16dd7be0
5 changed files with 81 additions and 33 deletions

View File

@@ -6,7 +6,7 @@ from sqlalchemy import func, select
from sqlalchemy.ext.asyncio import AsyncSession
from spoolman.database import models
from spoolman.database.utils import SortOrder
from spoolman.database.utils import SortOrder, add_where_clause_str
from spoolman.exceptions import ItemNotFoundError
@@ -47,8 +47,8 @@ async def find(
Returns a tuple containing the list of items and the total count of matching items.
"""
stmt = select(models.Vendor)
if name is not None:
stmt = stmt.where(models.Vendor.name.ilike(f"%{name}%"))
stmt = add_where_clause_str(stmt, models.Vendor.name, name)
total_count = None