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

selectPaths of partial object in array #83

Closed
brianorwhatever opened this issue Nov 11, 2024 · 3 comments
Closed

selectPaths of partial object in array #83

brianorwhatever opened this issue Nov 11, 2024 · 3 comments
Labels
CR1 This item was processed during the first Candidate Recommendation phase. editorial The item is editorial in nature. question Further information is requested

Comments

@brianorwhatever
Copy link

I believe I have implemented selectPaths and selectJsonLD correctly however I have a test failing that is supposed to select some of the elements of an object and drop the others. Here is the test:

const document = {
        '@context': {
          '@version': 1.1,
          'ex': 'https://example.org/vocab#',
          'credentials': 'ex:credentials'
        },
        'credentials': [
          { 'id': '1', 'type': 'A' },
          { 'id': '2', 'type': 'B' },
          { 'id': '3', 'type': 'C' }
        ]
      };

      const pointers = [
        '/credentials/0/id',
        '/credentials/0/type',
        '/credentials/2/id'
      ];
      const result = selectJsonLd(pointers, document);

and the resultant document is

{
    "@context": {
      "@version": 1.1,
      credentials: "ex:credentials",
      ex: "https://example.org/vocab#",
    },
    credentials: [
      {
        id: "1",
        type: "A",
      },
      {
        id: "3",
       type: "C",
      }
    ],
  }

so the array selection is working and making it dense.. however we are seeing the type: "C" property on the second element where I would expect to only see the id. I've traced it down pretty deep and in step 7 I am setting selectedValue properly but the selected Property already is:

{
  id: "3",
  type: "C",
}

Am I missing something?

@dlongley
Copy link
Contributor

See createInitialSelection which is called during step 5 of selectPaths whenever a new object in the path of a pointer is selected. The id (if not a blank node identifier) and type values are always included for objects in the path of a pointer (including the final target of the pointer).

@msporny msporny added question Further information is requested CR1 This item was processed during the first Candidate Recommendation phase. labels Dec 8, 2024
@msporny
Copy link
Member

msporny commented Dec 8, 2024

It's not clear if a change to the specification is required at this point. @brianorwhatever, thoughts?

@msporny msporny added the editorial The item is editorial in nature. label Dec 8, 2024
@brianorwhatever
Copy link
Author

This was an issue in the tests I had written not understanding the functions entirely. No spec changes required.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CR1 This item was processed during the first Candidate Recommendation phase. editorial The item is editorial in nature. question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants