40 lines
1.9 KiB
Diff
40 lines
1.9 KiB
Diff
From a2f5ed4e1bc2ae313ac8105348dc75f1e2186787 Mon Sep 17 00:00:00 2001
|
|
From: Charlie Unfricht <dzcharlie@gmail.com>
|
|
Date: Wed, 16 Jun 2021 17:05:46 -0400
|
|
Subject: [PATCH] Fix bad error check causing bulk import methods to fail
|
|
|
|
---
|
|
pyArango/collection.py | 12 ++++--------
|
|
1 file changed, 4 insertions(+), 8 deletions(-)
|
|
|
|
diff --git a/pyArango/collection.py b/pyArango/collection.py
|
|
index 7ee2061..3340096 100644
|
|
--- a/pyArango/collection.py
|
|
+++ b/pyArango/collection.py
|
|
@@ -748,10 +748,8 @@ def bulkImport_json(self, filename, onDuplicate="error", formatType="auto", **pa
|
|
data = f.read()
|
|
r = self.connection.session.post(url, params = params, data = data)
|
|
|
|
- try:
|
|
- errorMessage = "At least: %d errors. The first one is: '%s'\n\n more in <this_exception>.data" % (len(data), data[0]["errorMessage"])
|
|
- except KeyError:
|
|
- raise UpdateError(data['errorMessage'], data)
|
|
+ if r.status_code != 201:
|
|
+ raise UpdateError('Unable to bulk import JSON', r)
|
|
|
|
def bulkImport_values(self, filename, onDuplicate="error", **params):
|
|
"""bulk import from a file repecting arango's json format"""
|
|
@@ -763,10 +761,8 @@ def bulkImport_values(self, filename, onDuplicate="error", **params):
|
|
data = f.read()
|
|
r = self.connection.session.post(url, params = params, data = data)
|
|
|
|
- try:
|
|
- errorMessage = "At least: %d errors. The first one is: '%s'\n\n more in <this_exception>.data" % (len(data), data[0]["errorMessage"])
|
|
- except KeyError:
|
|
- raise UpdateError(data['errorMessage'], data)
|
|
+ if r.status_code != 201:
|
|
+ raise UpdateError('Unable to bulk import values', r)
|
|
|
|
def truncate(self):
|
|
"""deletes every document in the collection"""
|