-
Notifications
You must be signed in to change notification settings - Fork 146
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
removeMetadata #633
removeMetadata #633
Conversation
const meta = this.fetcher?.appNode // this.sym('chrome://TheCurrentSession') | ||
const linkNamespaceURI = 'http://www.w3.org/2007/ont/link#' | ||
const kb = this | ||
// removeMatches() --> removeMany() --> remove() fails on Collection |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't it be better to fix the remove() function to work with Collection instead of applying a workarround here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes it would. I did not find howto.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What goes wrong with when one f the nodes being removed is a collection?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for (var r = 0; r < requests.length; r++) { | ||
const request = requests[r] | ||
if (request !== undefined) { | ||
this.removeMatches(request, null, null, meta) | ||
if (request != null) { // null or undefined |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment says "or undefined" but the code onyl checks for null. Why?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Loose inequality does it
It is used in other places in rdflib
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think Angelo is correct. If you remove line 884 which checks for undefined, the !=null will throw an undefined error if request is undefined.
@@ -223,6 +223,17 @@ describe('UpdateManager', () => { | |||
expect(updater.editable(doc1)).to.equal(undefined) | |||
}) | |||
|
|||
it('Should not detect a document is editable from metadata after removeMetadata', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How are these tests related to the changes? I would have expected a test that assures that Collections are now working.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They test the new function removeMetadata
@jeff-zucker your test return not defined because foo is not declared.
```
const foo = undefined
if (foo == null)
```
Here foo is declared and has an undefined value
with the equality operator the result will be true when foo is null,
undefined or 0
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Equality
This is used in multiple location in Rdflib
Recently Tim has discovered an issue
#639 that seems due to using
deep equality and not equality
Le mer. 6 mars 2024, 18:46, Jeff Zucker ***@***.***> a écrit :
… ***@***.**** commented on this pull request.
------------------------------
In src/store.ts
<#633 (comment)>:
> for (var r = 0; r < requests.length; r++) {
const request = requests[r]
- if (request !== undefined) {
- this.removeMatches(request, null, null, meta)
+ if (request != null) { // null or undefined
**** I am not sure I understand this - if I create a file containing only if(foo
!= null) console.log(1); I get ReferenceError: foo is not **defined**. So
I don't see how this can work. I so much miss perl in this regard where you
could just say if(foo) and that would cover null, undefined, and empty.
—
Reply to this email directly, view it on GitHub
<#633 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAQ5TZTTKIWTQOXFBP27L2LYW5I6RAVCNFSM6AAAAABCY6JUSWVHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMYTSMRQGQZDINJXGU>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
AH! Thank you. It works if the variable is declared but not defined but
does not work if the variable is not declared, makes sense.
…On Sat, Mar 9, 2024 at 8:40 AM Alain Bourgeois ***@***.***> wrote:
@jeff-zucker your test return not defined because foo is not declared.
```
const foo = undefined
if (foo == null)
```
Here foo is declared and has an undefined value
with the equality operator the result will be true when foo is null,
undefined or 0
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Equality
This is used in multiple location in Rdflib
Recently Tim has discovered an issue
#639 that seems due to
using
deep equality and not equality
Le mer. 6 mars 2024, 18:46, Jeff Zucker ***@***.***> a écrit :
> ***@***.**** commented on this pull request.
> ------------------------------
>
> In src/store.ts
> <#633 (comment)>:
>
> > for (var r = 0; r < requests.length; r++) {
> const request = requests[r]
> - if (request !== undefined) {
> - this.removeMatches(request, null, null, meta)
> + if (request != null) { // null or undefined
>
> **** I am not sure I understand this - if I create a file containing
only if(foo
> != null) console.log(1); I get ReferenceError: foo is not **defined**.
So
> I don't see how this can work. I so much miss perl in this regard where
you
> could just say if(foo) and that would cover null, undefined, and empty.
>
> —
> Reply to this email directly, view it on GitHub
> <#633 (comment)>,
> or unsubscribe
> <
https://github.com/notifications/unsubscribe-auth/AAQ5TZTTKIWTQOXFBP27L2LYW5I6RAVCNFSM6AAAAABCY6JUSWVHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMYTSMRQGQZDINJXGU>
> .
> You are receiving this because you authored the thread.Message ID:
> ***@***.***>
>
—
Reply to this email directly, view it on GitHub
<#633 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AKVJCJELWNPTZWVI4JLJFY3YXM3QZAVCNFSM6AAAAABCY6JUSWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSOBWHEYTAOJYGI>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
I ran the attached script on solidcommunity.net and it errored with The same script on the test server did not produce an error. But it also did not remove all metadata about the document. Even after the new removeDocument(), there were three statements left over. The predicates related to the document that were not removed were acl, describedBy, and type - things from the link relations. I am not sure if it was intentional to leave these, but if not, it should be easy to fix. <script src="https://solidcommunity.net:8443/mashlib.js"></script>
<script type="module">
let doc = UI.rdf.sym("https://localhost:8443/public/s/test/tmpr/test.ttl");
async function test(){
await UI.store.fetcher.load(doc);
show('load');
await UI.store.removeDocument(doc);
show('removeDocument');;
}
test();
function show(msg){
let stmts = UI.store.match(null,null,null,doc);
console.log(`${stmts.length} statements with graph specified after ` + msg);
stmts = UI.store.match();
console.log(`${stmts.length} statements with graph not specified after ` + msg);
}
</script> The document in question looks like this:
The script output was this (notice the 3 in the last one) :
|
Also note that removeDocument did remove everything that had the document as the graph, but the three which were not removed had the document as subject and a blank node as the graph. |
Thanks @jeff-zucker for looking at this in detail.
The collection is in the metadata graph. (
Then these 3 statements are not related to either the graph document or the document part of the metadata graph They make no harm for the time being. So I prefer to keep these as an other issue. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll raise a separate issue on the un-removed link relations. Other than that, this looks good to go.
for (var r = 0; r < requests.length; r++) { | ||
const request = requests[r] | ||
if (request !== undefined) { | ||
this.removeMatches(request, null, null, meta) | ||
if (request != null) { // null or undefined |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think Angelo is correct. If you remove line 884 which checks for undefined, the !=null will throw an undefined error if request is undefined.
store.remove()
fails on triple containing aCollection