Skip to content

Commit

Permalink
Update more validations
Browse files Browse the repository at this point in the history
  • Loading branch information
Georgehe4 committed Nov 1, 2024
1 parent 0494e93 commit d3eee94
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions chromadb/api/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -623,9 +623,9 @@ def validate_where(where: Where) -> None:
# Value is a operator expression
if isinstance(value, dict):
# Ensure there is only one operator
if len(value) != 1:
if len(value) > 1:
raise ValueError(
f"Expected operator expression to have exactly one operator, got {value}"
f"Expected operator expression to have at most one operator, got {value}"
)

for operator, operand in value.items():
Expand Down Expand Up @@ -678,9 +678,9 @@ def validate_where_document(where_document: WhereDocument) -> None:
raise ValueError(
f"Expected where document to be a dictionary, got {where_document}"
)
if len(where_document) != 1:
if len(where_document) > 1:
raise ValueError(
f"Expected where document to have exactly one operator, got {where_document}"
f"Expected where document to have at most one operator, got {where_document}"
)
for operator, operand in where_document.items():
if operator not in ["$contains", "$not_contains", "$and", "$or"]:
Expand Down
4 changes: 2 additions & 2 deletions chromadb/segment/impl/metadata/grpc_segment.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,9 +330,9 @@ def _where_document_to_proto(
response = pb.WhereDocument()
if where_document is None:
return response
if len(where_document) != 1:
if len(where_document) > 1:
raise ValueError(
f"Expected where_document to have exactly one operator, got {where_document}"
f"Expected where_document to have at most one operator, got {where_document}"
)

for operator, operand in where_document.items():
Expand Down

0 comments on commit d3eee94

Please sign in to comment.