arturo-lang / grafito

Portable, Serverless & Lightweight SQLite-based Graph Database in Arturo
MIT License
145 stars 8 forks source link

Differentiate clearly between `[]` and `ø` (= `null`) #42

Open drkameleon opened 11 months ago

drkameleon commented 11 months ago

Right now, passing [] or ø (= as the "empty set" but actually an alias to null) are invariably meant to indicate "anything" or "everything".

So, for example person [] is supposed to mean: fetch all Person nodes that satisfy any criteria - or simply put: fetch all Person nodes.

This however leads to weird issues...

For example, let's say we form the - slightly more complicated - query below:

person [
    isFrom: country "Furance"
]

(as you can see, I have introduced a typo - that's on purpose)

So, what will country "Furance" return? Nothing. That's correct. But what is this nothing? An empty block: []

Now, take that and pass it back to our isFrom: edge filter. And think how this is interpreted: "fetch all Person nodes that isFrom... anywhere!". Which is obviously not what we need!

In that case, for example, country "Furance" should IMHO have returned null - meaning: I found nothing at all. And person should also return null since there are no people from a country called "Furance".

This way, we could actually etch "all people" (= all Person nodes), with the exact same syntax we do right now.

But even then, if we want to get rid of it as well, we could simply invent another symbol, alias to a specific type for example, and use that to mean "any". That could include any as a word too. Just thinking the whole thing over as I'm writing this! 😉