diff --git a/CHANGELOG.md b/CHANGELOG.md index 71166a9b..a878c220 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,6 +24,7 @@ - Preserved RDF literal lexical forms when converting through RDFLib, including canonical double output, large numeric values, and compound literal handling. - Fixed the active context clone dropping the default base direction: `@direction` now survives context layers like `@language`. Fixes [issue #337](https://github.com/digitalbazaar/pyld/issues/337). +- Fixed `@embed: @never` being ignored for reverse-framed properties because of a misspelled `embedded` framing state key. Fixes [issue #378](https://github.com/digitalbazaar/pyld/issues/378). - Fixed `KeyError` when a context sets `@direction: null` and no default base direction is in effect. - Fixed `iri_resolver.unresolve()` query/fragment reconstruction while cleaning up the resolver docstring. - Invalid IRI base values within lists are now skipped when serializing to RDF. Fixes [toRdf#tli12](https://w3c.github.io/json-ld-api/tests/toRdf-manifest#tli12) and [toRdf#tli14](https://w3c.github.io/json-ld-api/tests/toRdf-manifest#tli14). diff --git a/lib/pyld/jsonld.py b/lib/pyld/jsonld.py index cdc9159f..4d57012a 100644 --- a/lib/pyld/jsonld.py +++ b/lib/pyld/jsonld.py @@ -4660,7 +4660,7 @@ def _match_frame(self, state, subjects, frame, parent, property): {'propertyIsArray': True}, ) self._match_frame( - {**state, 'embeded': True}, + {**state, 'embedded': True}, [subject], subframe, output['@reverse'][reverse_prop], diff --git a/tests/jsonld/test_frame.py b/tests/jsonld/test_frame.py index 7258591b..443859d9 100644 --- a/tests/jsonld/test_frame.py +++ b/tests/jsonld/test_frame.py @@ -73,6 +73,41 @@ def test_frame_uses_identifier_issuer_option(): ] } +def test_frame_reverse_embed_never_is_respected(): + # Issue 378: a misspelled state key ignored @embed: @never in @reverse frames + ctx = { + "schema": "http://schema.org/", + "name": "schema:name", + "works_for": {"@id": "schema:worksFor", "@type": "@id"}, + "employees": {"@reverse": "schema:worksFor"}, + } + doc = { + "@context": ctx, + "@graph": [ + {"@id": "ex:org1", "@type": "schema:Organization", "name": "Acme"}, + { + "@id": "ex:p1", + "@type": "schema:Person", + "name": "Ada", + "works_for": "ex:org1", + }, + ], + } + nquads = jsonld.to_rdf(doc, {"format": "application/n-quads"}) + back = jsonld.from_rdf(nquads, {"format": "application/n-quads"}) + + result = jsonld.frame( + back, + { + "@context": ctx, + "@embed": "@once", + "@type": "schema:Organization", + "@reverse": {"schema:worksFor": {"@embed": "@never"}}, + }, + ) + + assert result["employees"] == {"@id": "ex:p1"} + # PR: https://github.com/digitalbazaar/pyld/pull/31 FRAME_0001_IN = {