Added backend filament search by similar color

This commit is contained in:
Donkie
2023-12-19 21:37:07 +01:00
parent 8322451f26
commit cf8d7472f5
5 changed files with 167 additions and 1 deletions

View File

@@ -2,7 +2,7 @@
from collections.abc import Sequence
from enum import Enum
from typing import Any, Optional, Union
from typing import Any, Optional, TypeVar, Union
import sqlalchemy
from sqlalchemy import Select
@@ -105,3 +105,17 @@ def add_where_clause_int_opt(
statements.append(field == value_part)
stmt = stmt.where(sqlalchemy.or_(*statements))
return stmt
T = TypeVar("T")
def add_where_clause_int_in(
stmt: Select,
field: attributes.InstrumentedAttribute[T],
value: Optional[Sequence[T]],
) -> Select:
"""Add a where clause to a select statement for a field."""
if value is not None and len(value) > 0:
stmt = stmt.where(field.in_(value))
return stmt