Skip to content
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
7 changes: 6 additions & 1 deletion arango/collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -1992,12 +1992,17 @@ def import_bulk(
IMPORTANT NOTE: this parameter may go through breaking changes
in the future where the return type may not be a list of result
objects anymore. Use it at your own risk, and avoid
depending on the return value if possible.
depending on the return value if possible. Cannot be used with
parameter **overwrite**.
:type batch_size: int
:return: Result of the bulk import.
:rtype: dict | list[dict]
:raise arango.exceptions.DocumentInsertError: If import fails.
"""
if overwrite and batch_size is not None:
msg = "Cannot use parameter 'batch_size' if 'overwrite' is set to True"
raise ValueError(msg)

documents = [self._ensure_key_from_id(doc) for doc in documents]

params: Params = {"type": "array", "collection": self.name}
Expand Down
4 changes: 4 additions & 0 deletions tests/test_document.py
Original file line number Diff line number Diff line change
Expand Up @@ -1843,6 +1843,10 @@ def test_document_import_bulk(col, bad_col, docs):
assert len(result) == 1
empty_collection(col)

# Test import bulk with overwrite and batch_size
with pytest.raises(ValueError):
col.import_bulk(docs, overwrite=True, batch_size=1)

# Test import bulk on_duplicate actions
doc = docs[0]
doc_key = doc["_key"]
Expand Down