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

cannot select the id field if it's BlankNodeId #22

Open
vigsterkr opened this issue Jun 11, 2020 · 1 comment
Open

cannot select the id field if it's BlankNodeId #22

vigsterkr opened this issue Jun 11, 2020 · 1 comment

Comments

@vigsterkr
Copy link
Contributor

say i have the following schema:

class A(JsonLDSchema):
   _id = fields.BlankNodeId()

class B(JsonLDSchema):
   _id = fields.BlankNodeId()
   value = fields.Nested(ML_SCHEMA.specifiedBy, A(only=("_id",)))

basically i only want to reference the A node....
this will basically yield in the following exception:

ValueError: Invalid fields for <ASchema(many=False)>: {'_id'}.

if i change ASchema::_id to fields.Id() it works, but even then it as well serializes the @type of the node, which i hoped that is not gonna be the case...

maybe it's related: when a field is BlankNodeId, then the @id is not serialized.

@Panaetius
Copy link
Member

fields.Nested is meant to serialize nested nodes, so it'll always add @type.

If you just want an id reference between them, you can pass flattened=True to the schema, then you get a flat list like

[
{'@id': 'a', '@type': 'A`},
{'@id': 'b', '@type': 'B', 'value': {'@id': 'a'}
]

Not sure if that helps you.

I'll take a look at the BlankNodeId's (they're somewhat experimental right now).

We also discussed adding an IRIField before for an unrelated issue, that would do 'value':{'@id': '...'} serialization from/to string, but that's more for when you want to reference an external IRI/URI.

Can you give an example with Schema's, the serialization command used and what the desired Json-LD would be?.

@Panaetius Panaetius added this to the sprint-2020-08-20 milestone Aug 19, 2020
@Panaetius Panaetius moved this to Backlog in renku-python May 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Backlog
Development

No branches or pull requests

2 participants