Skip to content

Framing doesn't compact a property if it is missing from the data (even when default is provided) #496

@cboettig

Description

@cboettig

@gkellogg sorry to bother you once more, I think this should be my last issue in my (miss)-handling of "@type" that causes me to get unexpected behavior.

Consider this data:

{
  "@context": {
    "schema": "http://schema.org/",
    "name": "schema:name",
    "url": {"@id": "schema:url", "@type": "schema:URL"}
  },
  "name": "Jane Doe"
}

Under this frame:

{
  "@context": {
    "schema": "http://schema.org/",
    "name": "schema:name",
    "url": { "@id": "schema:url", "@type": "schema:URL"}
  },
  "name": {},
  "url": {"@default": "http://example.com"}
}

The output url property cannot be compacted and remains as schema:url.

On one hand, this makes sense -- this is the same compaction behavior we would get if the input data did contain url but with a different type. Because the element is not present, that's kinda like not knowing it is typed correctly.

However, it would seem that this is clearly not the desired behavior for the developer, who expects to still be able to reference url and get back the default value. This all works as expected if the context doesn't declare an explicit data type for url. Perhaps a bug? But again I'm likely missing something. Thanks!

Playground

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions