terminusdb
terminusdb copied to clipboard
oneOf with multilevel inheritance
Describe the bug
I have a schema with two levels of inheritance. When I define a @oneOf property choice on the top-level abstract class, an error is thrown when I try to import an instance document for an inheriting class. I am able to import the instance document if I remove the intermediate class.
To Reproduce
- Import the schema below.
- Try to add the instance document that follows.
- See error below.
- Change the schema so that the
PersonNameclass inherits directly from theEntityclass. - The instance document is added as expected.
Expected behavior
It should be possible to add an instance document that inherits a @oneOf property choice from an arbitrary level of inheritance.
Info
- Latest TerminusDB
Additional context Schema:
[
{
"@base": "terminusdb:///data/",
"@schema": "terminusdb:///schema#",
"@type": "@context"
},
{
"@documentation": {
"@comment": "Personal name entity from the LC knowledge graph",
"@label": "Personal Name"
},
"@id": "PersonalName",
"@inherits": "LCEntity",
"@key": {
"@type": "Random"
},
"@type": "Class"
},
{
"@abstract": [],
"@documentation": {
"@comment": "Any entity type.",
"@label": "Entity"
},
"@id": "Entity",
"@key": {
"@type": "Random"
},
"@oneOf": { // `@oneOf` declaration
"authLabel": "xsd:string",
"varLabel": "xsd:string"
},
"@type": "Class",
"entityIRI": "xsd:anyURI"
},
{
"@abstract": [],
"@documentation": {
"@comment": "Entity in the Library of Congress knowledge graph",
"@label": "LC Entity"
},
"@id": "LCEntity",
"@inherits": "Entity",
"@key": {
"@type": "Random"
},
"@type": "Class"
}
]
Instance doc:
{
"@type":"PersonalName",
"@id":"PersonalName/a070ee3fd744b7d518ec0af9afada22a5900477479695ce4324f9292f949883f",
"entityIRI":"http://id.loc.gov/authorities/names/no94012141",
"authLabel":"dolph joseph n joseph norton 1835-1897"
}
Error:
{
"name": "Server request error",
"message": "Type error for \"dolph joseph n joseph norton 1835-1897\" which should be dict",
"data": {
"api:message": "Type error for \"dolph joseph n joseph norton 1835-1897\" which should be dict",
"api:status": "api:failure",
"system:witnesses": [
{
"@type": "vio:ViolationWithDatatypeObject",
"vio:literal": "\"dolph joseph n joseph norton 1835-1897\"",
"vio:message": "Type error for \"dolph joseph n joseph norton 1835-1897\" which should be dict",
"vio:type": "dict"
}
]
}
}