Skip to content

fix: Support BGPs with variables in SPARQL UPDATE queries - #786

Merged
jvherweg merged 1 commit into
mainfrom
feat/patch-where
Jun 28, 2021
Merged

jvherweg merged 1 commit into
mainfrom
feat/patch-where

Conversation

@jvherweg

Copy link
Copy Markdown
Member

Closes #784 and closes #15 (sort of).

Depends on #781.

The checks are there to make sure we only support BGP queries, but there's not really anything stopping us from allowing everything. At that point we could even remove the algebra body parser since we now only use it for validating.

@rubensworks rubensworks left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Just some thoughts that are probably better for a separate PR.

import type { Readable } from 'stream';
import type { ActorInitSparql } from '@comunica/actor-init-sparql';
import { newEngine } from '@comunica/actor-init-sparql';
import type { IQueryResultUpdate } from '@comunica/actor-init-sparql/lib/ActorInitSparql-browser';

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if (!(typeof op.where === 'undefined' || this.isBasicGraphPatternWithoutVariables(op.where))) {
this.logger.warn('WHERE statements are not supported');
throw new NotImplementedHttpError('WHERE statements are not supported');
if (!(typeof op.where === 'undefined' || op.where.type === Algebra.types.BGP)) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since it's possible to support other query types as well, why not expose a config option to just allow this? (perhaps via a separate PR?)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point for the future; we want to avoid applications depending on this though as it's not cross-implementation.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Also begs the question of how to advertise that functionality.)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we want to avoid applications depending on this though as it's not cross-implementation.

Ah yes, of course. The spec should be clear that client MUST NOT assume all servers have support for this, but that they MAY/SHOULD make use of it when they discover it.

(Also begs the question of how to advertise that functionality.)

Something like a profile for SPARQL Update media type in the Accept-Patch header may work here (but I would guess this has been suggested already in the Solid spec discussions).

this.applyOperation(result, (patch as SparqlUpdatePatch).algebra);
// Run the query through Comunica
const sparql = await readableToString(patch.data);
const query = await this.engine.query(sparql, { sources: [ result ]}) as IQueryResultUpdate;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this is not a problem in most cases, but for better performance, we may consider thinking about making Representation implement the RDFJS Store interface, so that it can be passed to the query engine directly.

@RubenVerborgh RubenVerborgh left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amazing!!!

Base automatically changed from feat/base-patch to main June 28, 2021 08:03
@jvherweg
jvherweg merged commit f299b36 into main Jun 28, 2021
@jvherweg
jvherweg deleted the feat/patch-where branch June 28, 2021 09:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SPARQL Update in Patch must allow WHERE How does PATCH work

3 participants