Skip to content

INSERT DATA Request appears to remove existing data in a resourceΒ #43

@jeswr

Description

@jeswr

Issue type:

  • πŸ› Bug

Description:

If I run the following script against the CSS at localhost:3000 then the result of the final CONSTRUCT query is just <ex:s> <ex:p> <ex:o2> when I would expect 3 triples; namely

<ex:s> <ex:p> <ex:o1>, <ex:o1.1>, <ex:o2>.
import { QueryEngine } from '@comunica/query-sparql-solid';
import { interactiveLogin } from 'solid-node-interactive-auth';
import cliSelect from 'cli-select';

async function getOidcIssuer() {
  console.log('Please select oidcIssuer:')
  const value = await cliSelect({
    values: [
      'https://login.inrupt.com/',
      'http://localhost:3000/'
    ]
  });
  if (!value) {
    throw new Error('Expected string');
  }
  return value.value;
}

async function main() {
  const myEngine = new QueryEngine();
  const oidcIssuer = await getOidcIssuer();
  const session = await interactiveLogin({ oidcIssuer });

  const bindings = await myEngine.queryBindings(`SELECT ?o WHERE { <${session.info.webId!}> <http://www.w3.org/ns/pim/space#storage> ?o }`, {
    sources: [ session.info.webId! ],
    '@comunica/actor-http-inrupt-solid-client-authn:session': session,
  });

  const bindingsArray = await bindings.toArray();

  let storage =
    // For ESS use pim:storage
    bindingsArray[0]?.get('o')?.value!
    // For CSS use webid with /profile/card#me stripped (hacky)
    || session.info.webId!.replace(/profile\/card\#me$/, '');


  const resource = `${storage}test-${Date.now()}.ttl`;

  // Create test.ttl (did not exist before)
  await myEngine.queryVoid(`INSERT DATA { <ex:s> <ex:p> <ex:o1> . <ex:s> <ex:p> <ex:o1.1> }`, {
    sources: [ resource ],
    '@comunica/actor-http-inrupt-solid-client-authn:session': session,
  });

  // Modify existing test.ttl
  await myEngine.queryVoid(`INSERT DATA { <ex:s> <ex:p> <ex:o2> }`, {
    sources: [ resource ],
    '@comunica/actor-http-inrupt-solid-client-authn:session': session,
  });

  // Get data in resource file
  const quads = await myEngine.queryQuads(`CONSTRUCT { ?s ?p ?o } WHERE { ?s ?p ?o }`, {
    sources: [ resource ],
    '@comunica/actor-http-inrupt-solid-client-authn:session': session,
  });

  console.log(JSON.stringify(await quads.toArray(), null, 2))
  
  await session.logout();
}

main();

Environment:

Crash log:

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    To Do (prio:low)

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions