You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
An or branch holding only an expression over outer variables never matches #620
An or / or-and branch whose expression clause reads a variable bound outside the or never matches, so the or drops rows it should keep. No error is raised.
Reproduction (v3 36d547ae, and main v2.0.7 228a0870)
The same happens in rule bodies (found while writing tests for #617 / PR #619).
Cause
apply_or_clauses (src/query/datalog/executor.rs), when no branch has not / not-join or reads metadata, evaluates each branch on its own from a single empty binding and joins the result with the incoming rows afterwards. evaluate_branch then applies the branch's expressions to rows where the outer variable is unbound, so the expression fails and the branch yields nothing. The seeded path (each incoming row seeds each branch), used when a branch has not / not-join, does not have this problem.
Fix direction
Use the seeded evaluation (or seed with the incoming bindings' values of the variables the branch reads) when a branch has an expression clause that reads a variable the branch's own patterns do not bind — as is already done for not / not-join and pseudo-attributes. Regression tests: the queries above, in a query and in a rule body, with the reorder switch on and off (tests/plan_independence_test.rs).
Related: #610 (an or sharing no variable with earlier clauses), #546 (or in the streaming engine).
Also affects or-join: (query [:find ?v :where [?e :n ?v] (or-join [?v] [(> ?v 1)] [(< ?v 0)])]) returns no rows (expected 2), from the same empty-seed path. Covered by the v3 fix.
Activity
adityamukho commentedon Oct 18, 2026
Also affects
or-join:(query [:find ?v :where [?e :n ?v] (or-join [?v] [(> ?v 1)] [(< ?v 0)])])returns no rows (expected 2), from the same empty-seed path. Covered by the v3 fix.Merge pull request #622 from project-minigraf/fix/620-or-outer-expr
fix(or): seed an or branch whose expression reads an outer variable (#…
release: v2.0.8
adityamukho commentedon Oct 20, 2026
Released in v2.0.8 (crates.io 2.0.8, 2026-10-20); also fixed on
v3for v3.0.0. Moved to "Fixed in v2.0.8" in #421.