diff --git a/python/tests/unit/connectors/memory/test_postgres_store.py b/python/tests/unit/connectors/memory/test_postgres_store.py index ad33d864ca9f..8355234cd954 100644 --- a/python/tests/unit/connectors/memory/test_postgres_store.py +++ b/python/tests/unit/connectors/memory/test_postgres_store.py @@ -2,7 +2,7 @@ import ast import asyncio -from collections.abc import AsyncGenerator +from collections.abc import AsyncGenerator, Callable from dataclasses import dataclass from typing import Annotated, Any from unittest.mock import AsyncMock, MagicMock, Mock, patch @@ -248,12 +248,32 @@ async def test_get_records(vector_store: PostgresStore, mock_cursor: Mock) -> No "filter, filter_sql, filter_params", [ (None, "", []), + ([], "", []), ("lambda x: x.id == 1", ' WHERE ("id" = %s)', [1]), + (lambda x: x.id == 1, ' WHERE ("id" = %s)', [1]), + (["lambda x: x.id == 1"], ' WHERE ("id" = %s)', [1]), + ([lambda x: x.id == 1], ' WHERE ("id" = %s)', [1]), ( ["lambda x: x.id > 0", "lambda x: x.id == 1 or x.id == 2"], ' WHERE ("id" > %s) AND (("id" = %s OR "id" = %s))', [0, 1, 2], ), + ( + [ + lambda x: x.id > 0, + lambda x: x.id == 1 or x.id == 2, + ], + ' WHERE ("id" > %s) AND (("id" = %s OR "id" = %s))', + [0, 1, 2], + ), + ( + [ + "lambda x: x.id > 0", + lambda x: x.id == 1 or x.id == 2, + ], + ' WHERE ("id" > %s) AND (("id" = %s OR "id" = %s))', + [0, 1, 2], + ), ], ) @pytest.mark.parametrize( @@ -274,7 +294,7 @@ async def test_vector_search( subquery_distance: str | None, include_vectors: bool, include_total_count: bool, - filter: str | list[str] | None, + filter: str | Callable | list[str | Callable] | None, filter_sql: str, filter_params: list[Any], ) -> None: