Above this code I’m asking for all TODO tasks, ?ignore is a map with all refs that I want to exclude.
The first example returns all tasks except the one with refs to one page included in ?ignore (expected behaviour).
The second throws all tasks including the ones I didn’t want to retrieve.
I’m sure it’s just a basic concept about this languaje that I missunderstood (I didn’t even know how is this called, datascript? datalog? datomic? clojurescript?.. I’m a bit confused).
PS. the way to look at the not clause in general is as such:
you make a dataset within that clause which then gets subtracted from the query results as they are.
The set that gets removed in your first example is any ?b entities with a reference from your ignore list
The set that gets removed in your second example is any ?name values that are in your ignore list.
And then you basically get what mentaloid indicates.
So the way to think of it is, “what subset of data do I wish to remove from my results?”
Whenever I get confused about what my not is suppose to be, I actually build a query trying to get the exact subset I don’t want to see. This will then inform my not clause.
those ?name values that are present in the ?ignore list
and therefore those ?ref entities with those ?name values as their :block/name
crucially that leaves all ?b entities that have a reference outside of the ignore list
regardless of whether it also has a reference present in the ignore list.
this is because :block/refs is not a single value
to work around the multiple values, we need to include the ?b entities in our subset
this way the ?b entity gets subtracted as a whole, even if there are references outside the ignore list.
Example 2 therefore only excludes ?b entities that only have references present in the ignore list.
And example 1 excludes all ?b entities that have 1 or more references in the ignore list.
I think I will just conclude not clauses can be very opaque if you want to understand them thoroughly.
I was trying to think of a way to better articulate how not clauses work, but I feel I’m writing in circles.
And as you demonstrated already, when it comes to nesting it gets even more confusing! I have such an example in my own graph:
Block that don’t have a reference
and whose lineage doesn’t have a reference
don’t count references to note or activity, as having a reference
Perhaps it is a language barrier thing, for me except is not natural
I mean in the not clause sense of using it.
I guess that’s why I went for the “not count as” wording.
Other than would work I guess. Not sure why I’m tripping over the word except.
Probably a language barrier that I use simpler/less specific terms.