Skip to content

fix(graph): EDGE WHERE follows SQL three-valued NULL logic - #480

Draft
EnRaiha wants to merge 2 commits into
NodeDB-Lab:mainfrom
EnRaiha:fix/graph-edge-null-metadatafilter
Draft

EnRaiha wants to merge 2 commits into
NodeDB-Lab:mainfrom
EnRaiha:fix/graph-edge-null-metadatafilter

Conversation

@EnRaiha

@EnRaiha EnRaiha commented Nov 21, 2026

Copy link
Copy Markdown
Contributor

= NULL and <> NULL on a literal converted to the same filter as IS NULL and IS NOT NULL, so a comparison against the NULL literal wrongly matched a missing or present-NULL property. A comparison against NULL is always unknown, so it now never admits, for every property regardless of whether it is missing, holds NULL, or holds a value. IS NULL and IS NOT NULL convert through their own branch and keep their documented behavior.

IN and NOT IN read a present NULL property, or a NULL list element, as a definite match. Both now follow the unknown rule: a present NULL property never admits either, and a NULL anywhere in the list excludes NOT IN outright, even when the property matches nothing else in that list. The missing-property rule for IN and NOT IN is unchanged.

`= NULL` and `<> NULL` on a literal converted to the same filter as
`IS NULL` and `IS NOT NULL`, so a comparison against the NULL literal
wrongly matched a missing or present-NULL property. A comparison
against NULL is always unknown, so it now never admits, for every
property regardless of whether it is missing, holds NULL, or holds a
value. IS NULL and IS NOT NULL convert through their own branch and
keep their documented behavior.

IN and NOT IN read a present NULL property, or a NULL list element,
as a definite match. Both now follow the unknown rule: a present NULL
property never admits either, and a NULL anywhere in the list
excludes NOT IN outright, even when the property matches nothing else
in that list. The missing-property rule for IN and NOT IN is
unchanged.
NOT (w = NULL) and NOT (w <> NULL) admitted every edge unconditionally.
never_admits() built the same Or(Vec::new()) shape a literal FALSE
converts to, so the shared MetadataFilter::Not evaluator's plain
boolean negation flipped it to true -- SQL's NOT UNKNOWN is UNKNOWN,
not TRUE.

never_admits() now returns Or(vec![Or(Vec::new())]), a shape convert()'s
own Not arm recognizes and returns unchanged instead of wrapping,
keeping it self-negating under any number of NOTs. The nested Or, not
And: parse_edge_predicate flattens a top-level And into its own AND-ed
clause list, which would have stripped an And-shaped marker exactly
when the NULL comparison is the whole predicate.

IN/NOT IN under NOT has a separate, pre-existing issue of the same
general shape (NOT (w IN (1, NULL)) also mishandles NULL), not touched
here: it does not go through never_admits() at all, and is a deeper
problem in the shared In/NotIn match-time evaluator, not a clean
regression this fix introduced.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant