terminusdb icon indicating copy to clipboard operation
terminusdb copied to clipboard

oneOf with multilevel inheritance

Open timathom opened this issue 2 years ago • 0 comments

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

  1. Import the schema below.
  2. Try to add the instance document that follows.
  3. See error below.
  4. Change the schema so that the PersonName class inherits directly from the Entity class.
  5. 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"
      }
    ]
  }
}

timathom avatar Dec 12 '23 22:12 timathom