Skip to content

vectorstore: Fix in exists operator. Was working as null #51

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion langchain_postgres/vectorstores.py
Original file line number Diff line number Diff line change
Expand Up @@ -720,7 +720,7 @@ def _handle_field_filter(
self.EmbeddingStore.cmetadata,
field,
)
return ~condition if filter_value else condition
return condition if filter_value else ~condition
else:
raise NotImplementedError()

Expand Down
8 changes: 4 additions & 4 deletions tests/unit_tests/fixtures/filtering_test_cases.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,19 +226,19 @@
TYPE_6_FILTERING_TEST_CASES = [
# These involve the special operator $exists
(
{"happiness": {"$exists": True}},
{"happiness": {"$exists": False}},
[],
),
(
{"happiness": {"$exists": False}},
{"happiness": {"$exists": True}},
[1, 2, 3],
),
(
{"sadness": {"$exists": True}},
{"sadness": {"$exists": False}},
[3],
),
(
{"sadness": {"$exists": False}},
{"sadness": {"$exists": True}},
[1, 2],
),
]
Loading