antoniogarrote / rdfstore-js

JS RDF store with SPARQL support
MIT License
563 stars 109 forks source link

Deleting any node deletes all node #159

Open parliament718 opened 5 years ago

parliament718 commented 5 years ago

I know this library is unmaintained but it really really sucks that I cant do a basic delete operation. It keeps deleting all my data no mattter what method of delete I try.

I'm able to retrieve a subset of my graph from rdfstore.js via the following query:

SELECT * { 
    ?subject app:rhymesWith ?object .
    FILTER (?subject = "word" || ?object = "word")
}

However, when I try to delete what I would think is the same subset of triples:

DELETE WHERE {
     ?subject app:rhymesWith ?object .
     FILTER(?subject = "word" || ?object = "word")
}

It deletes all data in my graph. I tried many other methods including the RDF Interface API:

this.store.graph('app:graph', async (err, graph) => {
                const rdf = this.store.rdf;

                 //deleteGraph  here even has the correct number of triples to delete
                let deleteGraph = graph.match(
                    null,
                    rdf.createNamedNode(rdf.resolve("app:rhymesWith")),
                    rdf.createLiteral(word));

                this.store.delete(deleteGraph);
            });

I've even used DELETE DATA to try to delete a single triplet without any pattern matching:

    let data = `"${triple.subject}" app:rhymesWith "${triple.object}"`;
   let query = `DELETE DATA { GRAPH app:graph { ${data} } } `;

    this.store.execute(query);

No matter what I do, any kind of delete attempt deletes all the data. Very upsetting as I have invested a quite bit of time into writing and querying the data, now I cant delete anything and have to rewrite the whole thing in a diff lib. Is there any solution at all?

madnificent commented 5 years ago

@parliament718 Did you work further on a solution to this problem? We're looking into using rdfstore-js too and data-deletion would be an important feature.

Did you try stepping through the code to see what was wrong, or have you only tried different ways of deleting content?

If you have alternative libraries which allow us to do similar things, I'd like to hear about them too.

parliament718 commented 5 years ago

@madnificent unfortunately no, I did not find any solution nor insight into this bug. Sorry, but if you do please let me know!