Entity / Expressions
How three interpreters share one expression
Every Expr value is interpreted by three engines depending on where it runs:
- SQL compiler (
foldkit-remote-drizzle): Translates the expression into parameterized SQLite, Postgres, or D1 queries. - In-memory evaluator (
evaluate): Runs the expression over a complete table of rows in memory. - Partial holder judge (
Judge): Evaluates the expression over whatever rows and fields the browser currently holds, returningKnown(true | false | unknown)when decidable orUnknown(reason)when a required row or field is missing.
Two rules guarantee that SQL and memory produce identical results:
- Three-valued SQL logic: Comparing with
nullyields unknown, and rows match only when the predicate evaluates totrue. - Explicit backend parity: Text ordering declares its collation,
containsspecifies ASCII case folding, and inputs that databases handle inconsistently (strings containing NUL bytes, orNaN) fail explicitly.