Craticula

Null handling

A text field is blank when it is null or empty, and any other field is blank only when it is null. Not blank is exactly the opposite of blank. On an engine that stores an empty string as null, such as Oracle, the check reduces to null alone.

Rule. The unary operators blank/notBlank ($defs/unaryOperator) resolve as: blank ⇔ IS NULL OR = '' for text fields, IS NULL for every other type; notBlank is blank's exact Boolean negation (never a separately-derived condition that could disagree with it at the edges). (The text arm is per-engine as well as per-type: on a backend whose empty string is NULL — Oracle among the SQL dialects — it collapses to IS NULL, and emitting the = '' disjunct there makes notBlank match nothing at all. The negation rule above is unaffected. See SQL-7 in the canonical-SQL-rendering addendum for the truth table and the reason it is a correctness rule.) Negative binary/set operators — neq, notContains, notIn — MUST include NULL-valued rows in their match set. A negative comparison compiles as, e.g., col <> :v OR col IS NULL, never a bare col <> :v. The same null-inclusive rule applies to a tree-level $defs/notNode wrapping any child (Not(Comparison(...)), Not(And(...)), Not(Or(...)), arbitrarily nested) — not just the negative operators above. AG Grid's client-side row model has no tree-level NOT construct to take as a reference point, but its own rationale extends cleanly: a NOT that excludes a NULL/missing row just because SQL's three-valued logic happens to do so is the identical bug this rule exists to prevent, one syntax level up. Concretely, Not(Comparison(field, contains, X)) on SQL compiles as (NOT (col ILIKE '%'||:v||'%') OR col IS NULL) — the OR col IS NULL is mandatory on the outside of the NOT, exactly mirroring neq's own compiled shape — and the same fan-out is emitted by every backend at every notNode, at every nesting depth, whatever the child is: one "this field is null/missing" disjunct per distinct field referenced in the negated subtree, in first-appearance order, outside the negation. Not(And(Or(Not(eq status X)))) therefore carries the disjunct at both not nodes. Mongo's $nor and ES's must_not are not a substitute: they include a null document only when the child does not match it, and a child such as neq, blank or an inner not, or an or whose other field matches, does match one — the null row would then be dropped by exactly the bug this rule exists to prevent. The disjunct is {field: null} on MongoDB and must_not: exists on the raw field on OpenSearch/Elasticsearch (MDB-2, OSE-2).

Rationale. AG Grid's in-memory row model filters with plain JavaScript equality, where a missing or null cell value is simply "not equal" to any concrete filter value — so neq in the client-side row model always includes rows with a null/missing value for that column. SQL's three-valued logic does the opposite by default: NULL <> 'Alice' evaluates to NULL (neither true nor false), so a bare WHERE name <> 'Alice' silently excludes every NULL row from the result — the naive, "obviously correct" translation is actually the wrong answer, and it disagrees with what the same filter would have shown against the same dataset in the client-side row model. This divergence is exactly the "broken null semantics" the TRD's problem statement (§1) flags as one of the two most common ways this translation goes wrong (case sensitivity being the other, SEM-1). Pinning the answer — NULLs match negative operators — makes every backend agree with each other and with AG Grid's own non-SSRM behavior.

Worked example — neq: "Alice" against a name field where some rows have name IS NULL:

Must NOT.

Cross-links. $defs/unaryOperator (blank, notBlank), $defs/binaryOperator (neq), $defs/setOperator (notIn), $defs/nullValue, SQL-2 and SQL-7 (the compiled shapes of blank/notBlank, per construct and per engine).