Skip to content

Commit b3af249

Browse files
authored
Fix conversion of sys:JSON type schema to Python (terminusdb#400)
If a class contained a "sys:JSON" property, it wouldn't convert to a normal Python class as it should. Fixes issue terminusdb#397
1 parent fd967e4 commit b3af249

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

terminusdb_client/tests/test_Schema.py

+21
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,27 @@ def test_embedded_object(test_schema):
206206
assert (len(result) == 2)
207207

208208

209+
def test_person_sys_json():
210+
schema_json = {
211+
"@id": "PersonJSONTest",
212+
"@key": {
213+
"@type": "Random"
214+
},
215+
"@type": "Class",
216+
"metadata": {
217+
"@class": "sys:JSON",
218+
"@type": "Optional"
219+
}
220+
}
221+
schema = Schema()
222+
test_result = schema._construct_class(schema_json)
223+
result = {'@id': 'PersonJSONTest',
224+
'@key': {'@type': 'Random'},
225+
'@type': 'Class',
226+
'metadata': {'@class': 'sys:JSON', '@type': 'Optional'}}
227+
assert test_result._to_dict() == result
228+
229+
209230
def test_id_and_capture(test_schema):
210231
my_schema = test_schema
211232
Person = my_schema.object.get("Person")

terminusdb_client/woql_type.py

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
bool: "xsd:boolean",
88
float: "xsd:double",
99
int: "xsd:integer",
10+
dict: "sys:JSON",
1011
dt.datetime: "xsd:dateTime",
1112
dt.date: "xsd:date",
1213
dt.time: "xsd:time",

0 commit comments

Comments
 (0)