fluree / db

Fluree database library
https://fluree.github.io/db/
Other
330 stars 21 forks source link

shacl:class validation doesn't seem to observe inheritance #735

Open chrisdostert opened 4 months ago

chrisdostert commented 4 months ago

repro

  1. create a class "Offering"

    {
    "@id": "Offering",
    "@type": [
      "rdfs:Class",
      "shacl:NodeShape"
    ],
    "shacl:property": [
      {
        "shacl:maxCount": 1,
        "shacl:minCount": 1,
        "shacl:dataType": {
          "@id": "xsd:string"
        },
        "shacl:path": {
          "@id": "name"
        }
      }
    ]
    }
  2. create a child class "ServiceOffering" that is rdfs:subClassOf Offering

    
    {
    "@id": "ServiceOffering",
    "@type": [
      "rdfs:Class",
      "shacl:NodeShape"
    ],
    "rdfs:subClassOf": {
      "@id": "Offering"
    },
    "shacl:property": [
      {
        "shacl:maxCount": 1,
        "shacl:minCount": 1,
        "shacl:dataType": {
          "@id": "xsd:integer"
        },
        "shacl:path": {
          "@id": "price"
        }
      }
    ]
    }
  3. create a "Charge" class

    {
    "@id": "Charge",
    "@type": [
      "rdfs:Class",
      "shacl:NodeShape"
    ],
    "shacl:targetClass": {
      "@id": "Charge"
    },
    "shacl:property": [
      {
        "shacl:class": {
          "@id": "Offering"
        },
        "shacl:maxCount": 1,
        "shacl:minCount": 1,
        "shacl:path": {
          "@id": "for"
        }
      }
    ]
    }
  4. Create a ServiceOffering

  5. Create a Charge referencing the ServiceOffering

expected

it works with no errors

actual

{"error":"db/shacl-validation","cause":"SHACL PropertyShape exception - sh:class: class(es) #{211106232533039} must be same set as #{211106232533465}."}

Of note: if you change the shacl constraint in Charge Class from

        "shacl:class": {
          "@id": "Offering"
        },

to

        "shacl:class": {
          "@id": "ServiceOffering"
        },

the error goes away so it seems It's not observing inheritance.

chrisdostert commented 3 months ago

possibly related to https://github.com/fluree/db/issues/706 ?