Skip to content

Commit 7cf7355

Browse files
committed
Update to
1 parent bb5e19a commit 7cf7355

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

langchain_postgres/vectorstores.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ class DistanceStrategy(str, enum.Enum):
6666
"$in",
6767
"$nin",
6868
"$between",
69-
"$null",
69+
"$exists",
7070
}
7171

7272
TEXT_OPERATORS = {
@@ -710,10 +710,10 @@ def _handle_field_filter(
710710
return queried_field.ilike(filter_value)
711711
else:
712712
raise NotImplementedError()
713-
elif operator == "$null":
713+
elif operator == "$exists":
714714
if not isinstance(filter_value, bool):
715715
raise ValueError(
716-
"Expected a boolean value for $null "
716+
"Expected a boolean value for $exists "
717717
f"operator, but got: {filter_value}"
718718
)
719719
condition = func.jsonb_exists(

tests/unit_tests/fixtures/filtering_test_cases.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -226,19 +226,19 @@
226226
TYPE_6_FILTERING_TEST_CASES = [
227227
# These involve the special operator $null
228228
(
229-
{"happiness": {"$null": True}},
229+
{"happiness": {"$exists": True}},
230230
[],
231231
),
232232
(
233-
{"happiness": {"$null": False}},
233+
{"happiness": {"$exists": False}},
234234
[1, 2, 3],
235235
),
236236
(
237-
{"sadness": {"$null": True}},
237+
{"sadness": {"$exists": True}},
238238
[3],
239239
),
240240
(
241-
{"sadness": {"$null": False}},
241+
{"sadness": {"$exists": False}},
242242
[1, 2],
243243
),
244244
]

tests/unit_tests/test_vectorstore.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -508,8 +508,8 @@ def test_pgvector_with_with_metadata_filters_6(
508508
{"$and": {}},
509509
{"$between": {}},
510510
{"$eq": {}},
511-
{"$null": {}},
512-
{"$null": 1},
511+
{"$exists": {}},
512+
{"$exists": 1},
513513
],
514514
)
515515
def test_invalid_filters(pgvector: PGVector, invalid_filter: Any) -> None:
@@ -524,6 +524,7 @@ def test_validate_operators() -> None:
524524
"$and",
525525
"$between",
526526
"$eq",
527+
"$exists",
527528
"$gt",
528529
"$gte",
529530
"$ilike",
@@ -533,6 +534,5 @@ def test_validate_operators() -> None:
533534
"$lte",
534535
"$ne",
535536
"$nin",
536-
"$null",
537537
"$or",
538538
]

0 commit comments

Comments
 (0)