From 73d16ea358c439cf22c73403cd234ec14938be38 Mon Sep 17 00:00:00 2001 From: Eugene Yurtsev Date: Mon, 10 Jun 2024 14:23:52 -0400 Subject: [PATCH 1/2] x --- .../fixtures/filtering_test_cases.py | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/tests/unit_tests/fixtures/filtering_test_cases.py b/tests/unit_tests/fixtures/filtering_test_cases.py index 514a10f1..e27d71d0 100644 --- a/tests/unit_tests/fixtures/filtering_test_cases.py +++ b/tests/unit_tests/fixtures/filtering_test_cases.py @@ -203,11 +203,39 @@ {"name": {"$in": ["adam", "bob"]}}, [1, 2], ), + # With numeric fields + ( + {"id": {"$in": [1, 2]}}, + [1, 2], + ), # Test nin ( {"name": {"$nin": ["adam", "bob"]}}, [3], ), + ## with numeric fields + ( + {"id": {"$nin": [1, 2]}}, + [3], + ), + # With boolean fields + ( + {"is_active": {"$in": [True]}}, + [1, 3], + ), + ( + {"is_active": {"$nin": [True]}}, + [2], + ), + # With null fields + ( + {"happiness": {"$in": [None]}}, + [3], + ), + ( + {"happiness": {"$nin": [None]}}, + [1, 2], + ), ] TYPE_5_FILTERING_TEST_CASES = [ From 82f14ba1c90b728cded62cc1aeb60959be46276f Mon Sep 17 00:00:00 2001 From: Eugene Yurtsev Date: Mon, 10 Jun 2024 14:29:43 -0400 Subject: [PATCH 2/2] x --- langchain_postgres/vectorstores.py | 5 +++++ .../fixtures/filtering_test_cases.py | 18 ------------------ 2 files changed, 5 insertions(+), 18 deletions(-) diff --git a/langchain_postgres/vectorstores.py b/langchain_postgres/vectorstores.py index 659b6f32..2d72dc97 100644 --- a/langchain_postgres/vectorstores.py +++ b/langchain_postgres/vectorstores.py @@ -1074,6 +1074,11 @@ def _handle_field_filter( f"Unsupported type: {type(val)} for value: {val}" ) + if isinstance(val, bool): # b/c bool is an instance of int + raise NotImplementedError( + f"Unsupported type: {type(val)} for value: {val}" + ) + queried_field = self.EmbeddingStore.cmetadata[field].astext if operator in {"$in"}: diff --git a/tests/unit_tests/fixtures/filtering_test_cases.py b/tests/unit_tests/fixtures/filtering_test_cases.py index e27d71d0..701260c0 100644 --- a/tests/unit_tests/fixtures/filtering_test_cases.py +++ b/tests/unit_tests/fixtures/filtering_test_cases.py @@ -218,24 +218,6 @@ {"id": {"$nin": [1, 2]}}, [3], ), - # With boolean fields - ( - {"is_active": {"$in": [True]}}, - [1, 3], - ), - ( - {"is_active": {"$nin": [True]}}, - [2], - ), - # With null fields - ( - {"happiness": {"$in": [None]}}, - [3], - ), - ( - {"happiness": {"$nin": [None]}}, - [1, 2], - ), ] TYPE_5_FILTERING_TEST_CASES = [