Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

oneOf with multilevel inheritance #2066

Open
timathom opened this issue Dec 12, 2023 · 0 comments
Open

oneOf with multilevel inheritance #2066

timathom opened this issue Dec 12, 2023 · 0 comments
Labels
bug Something isn't working

Comments

@timathom
Copy link

timathom commented Dec 12, 2023

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 timathom added the bug Something isn't working label Dec 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant