rdflib.js
rdflib.js copied to clipboard
Update applyPatch function and add tests for it
The applyPatch function had a few small bugs when I tried it, so I fixed those and added tests for the function
Hi and thanks for your contribution. Can you please describe what bugs you experienced and how your changes fix those?
The bugs I found:
- the
substitutefunction of a collection didn't seem to work with the current constructor, creating a new collection and adding the elements did work - in the
applyPatchfunctionpatch['insert']was always used, but in the function declaration it said'patch' - the
ds = ds.statementsline meant that if there was a where clause this statement would be executed twice instead of once which meant there would suddenly need to be ads.statements.statements - since the other functions seem to assume
dsis a collection and the elements of a collection are accessed viaelementsand notstatementsI edited that as well - the
targetKB.queryfunction failed because theinitBindingswas always undefined, the code seemed to assume it's a list so I made it an empty list
Looking back at this now it is merged (and broken for solid-ui.) ds was designed to be an Array, not a Collection - which code expects it to be a Collection?
So the test is wrong too. The parameters are expected to be IndexedFormulas, not collections. Let's roll this back. Sorry I don't read it carefully in review.