Skip to content

Commit

Permalink
Add delete tests back and where_document null handling (#137)
Browse files Browse the repository at this point in the history
  • Loading branch information
HammadB authored Feb 16, 2023
1 parent 0abd05c commit 9ce6189
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
11 changes: 8 additions & 3 deletions chromadb/api/local.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,12 +152,12 @@ def _get(
offset=None,
page=None,
page_size=None,
where_document=None
where_document=None,
):

if where is None:
where = {}

if where_document is None:
where_document = {}

Expand All @@ -182,7 +182,12 @@ def _delete(self, collection_name, ids=None, where=None, where_document=None):
if where is None:
where = {}

deleted_uuids = self._db.delete(collection_name=collection_name, where=where, ids=ids, where_document=where_document)
if where_document is None:
where_document = {}

deleted_uuids = self._db.delete(
collection_name=collection_name, where=where, ids=ids, where_document=where_document
)
return deleted_uuids

def _count(self, collection_name):
Expand Down
7 changes: 2 additions & 5 deletions chromadb/test/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,11 +233,8 @@ def test_delete(api_fixture, request):
collection.add(**batch_records)
assert collection.count() == 2

# generic delete on collection not working yet
# assert collection.delete() == []
# assert collection.count() == 2
# assert collection.delete()
# assert collection.count() == 0
collection.delete()
assert collection.count() == 0


@pytest.mark.parametrize("api_fixture", test_apis)
Expand Down

0 comments on commit 9ce6189

Please sign in to comment.