@@ -169,18 +169,13 @@ def _prep_from_doc(
169
169
else :
170
170
return doc_id , doc_id , {"If-Match" : rev }
171
171
172
- def _ensure_key_in_body (self , body : Json , index : Optional [int ] = None ) -> Json :
173
- """Return the document body with "_key" field populated. If
174
- neither "_key" or "_id" exist, set "_key" value to **index**,
175
- where **index** is the document's position in the sequence.
176
-
172
+ def _ensure_key_in_body (self , body : Json ) -> Json :
173
+ """Return the document body with "_key" field populated.
177
174
:param body: Document body.
178
175
:type body: dict
179
- :param index: Document index value in the original list of documents.
180
- :param index: int | None
181
176
:return: Document body with "_key" field.
182
177
:rtype: dict
183
- :raise arango.exceptions.DocumentParseError: On missing _key, _id, & index .
178
+ :raise arango.exceptions.DocumentParseError: On missing ID and key .
184
179
"""
185
180
if "_key" in body :
186
181
return body
@@ -189,11 +184,6 @@ def _ensure_key_in_body(self, body: Json, index: Optional[int] = None) -> Json:
189
184
body = body .copy ()
190
185
body ["_key" ] = doc_id [len (self ._id_prefix ) :]
191
186
return body
192
- elif index is not None :
193
- body = body .copy ()
194
- body ["_key" ] = str (index )
195
- return body
196
-
197
187
raise DocumentParseError ('field "_key" or "_id" required' )
198
188
199
189
def _ensure_key_from_id (self , body : Json ) -> Json :
@@ -2001,9 +1991,7 @@ def import_bulk(
2001
1991
:rtype: dict
2002
1992
:raise arango.exceptions.DocumentInsertError: If import fails.
2003
1993
"""
2004
- documents = [
2005
- self ._ensure_key_in_body (doc , i ) for i , doc in enumerate (documents , 1 )
2006
- ]
1994
+ documents = [self ._ensure_key_from_id (doc ) for doc in documents ]
2007
1995
2008
1996
params : Params = {"type" : "array" , "collection" : self .name }
2009
1997
if halt_on_error is not None :
0 commit comments