Skip to content

Commit 89fd54d

Browse files
committed
Restore funky diag. record rubbish values
1 parent d0cc695 commit 89fd54d

File tree

2 files changed

+29
-2
lines changed

2 files changed

+29
-2
lines changed

nutkit/protocol/cypher.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -496,4 +496,18 @@ def as_cypher_type(value):
496496
return CypherString(value)
497497
if isinstance(value, (bytes, bytearray)):
498498
return CypherBytes(value)
499+
if isinstance(
500+
value,
501+
(
502+
CypherNode,
503+
CypherRelationship,
504+
CypherPath,
505+
CypherPoint,
506+
CypherDate,
507+
CypherTime,
508+
CypherDateTime,
509+
CypherDuration,
510+
)
511+
):
512+
return value
499513
raise TypeError("Unsupported type: {}".format(type(value)))

tests/stub/errors/test_errors.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,9 @@ def test_filling_default_value_in_diagnostic_record(self):
283283
self._assert_is_test_error(error, error_data)
284284

285285
def test_keeps_rubbish_in_diagnostic_record(self):
286+
use_spacial = self.driver_supports_features(
287+
types.Feature.API_TYPE_SPATIAL
288+
)
286289
for as_cause in (False, True):
287290
with self.subTest(as_cause=as_cause):
288291
diagnostic_record = {
@@ -292,16 +295,26 @@ def test_keeps_rubbish_in_diagnostic_record(self):
292295
"CURRENT_SCHEMA": {"uh": "oh!"},
293296
"OPERATION_CODE": False,
294297
"_classification": 42,
295-
# stub script will interpret this as JOLT bytes
296-
"_status_parameters": {"Hello": "Goodbye"},
298+
"_status_parameters": [
299+
# stub script will interpret this as JOLT spatial point
300+
{"@": "SRID=4326;POINT(56.21 13.43)"}
301+
if use_spacial
302+
else "whatever",
303+
],
297304
}
298305
error_data = self._make_test_error_data(
299306
diagnostic_record=diagnostic_record,
300307
code=None if as_cause else ...,
301308
)
302309
if as_cause:
303310
error_data = self._make_test_error_data(cause=error_data)
311+
304312
error = self.get_error(error_data)
313+
314+
if use_spacial:
315+
diagnostic_record["_status_parameters"] = [
316+
types.CypherPoint("wgs84", 56.21, 13.43)
317+
]
305318
self._assert_is_test_error(error, error_data)
306319

307320
def test_error_retryable(self):

0 commit comments

Comments
 (0)