Repository navigation
fix(query): expression = / != equate a keyword with a ref to its entity (#744) - #748
Merged
Merged
Conversation
This was referenced Oct 24, 2026
Merged
adityamukho
force-pushed
the
fix/744-expr-keyword-ref
branch
from
October 24, 2026 14:26
282b17d to
ffddee0
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
…ty (#744) Patterns, joins, not bodies and or branches treat a keyword as equal to a ref to the entity it names; eval_binop compared the two Values as they are, so [(= ?g :bob)] kept no row where [?x :ref/friend :bob] matched one, and != kept it. Eq/Neq now use expr_eq: structural equality, except that a keyword equals a ref to the entity edn_to_entity_id derives from it. Ordering comparisons on keywords and refs stay a type mismatch. The frozen engine answer to [?e :person/self ?v] [(= ?e ?v)] (keyword :pN on entity :pN) changes from 0 rows to the rows [?e :person/self ?e] returns, at each temporal setting. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Urda7FD9CYYoxdeGGJa11x
…ounts Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Urda7FD9CYYoxdeGGJa11x
adityamukho
force-pushed
the
fix/744-expr-keyword-ref
branch
from
October 24, 2026 20:03
ffddee0 to
f73ec91
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68B5
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
For #744 (data-integrity, open until the v2.x backport is released).
Problem
Patterns, joins,
notbodies andorbranches treat the keyword:bobas equal to a ref to the entity:bobnames. An expression's=/!=compared the twoValues as they are, so with?gbound to that ref,[(= ?g :bob)]kept no row and[(!= ?g :bob)]kept it. Same question, different answer, no error.Change
eval_binop(src/query/datalog/executor.rs) compares=/!=with a newexpr_eq: structural equality, except that a keyword equals a ref to the entityedn_to_entity_idderives from it (the derivationIdSpace::keyword_eiduses, UUID-named keywords included).<,>,<=,>=on a keyword or a ref stay a type mismatch (no row). Neither is ordered today, so this introduces no new disagreement.Frozen answers
tests/answers/engine_tests.txt: 24 lines change, all for[?e :person/self ?v] [(= ?e ?v)](the fixture stores the keyword:pNon entity:pN) at its 13 temporal settings, in memory and across checkpoint/reopen. It went from 0 rows to the rows[?e :person/self ?e]returns. Each changed hash was matched to that query text.Tests
tests/join_rules_test.rs(+4): both operand orders, a keyword constant and value,!=, a binding expression, a boundVal(Ref), a rule body,not, anorbranch, a UUID-named keyword, set elements, in memory, after a checkpoint and after reopen. They failed before the fix.Full suite: default 1,766 passed / 13 ignored;
--features test-hooks1,784 / 14 (after rebase on #743);cargo fmt --checkandcargo clippy --all-features -- -D warningsclean.Codex review: one finding (that
[(= ?v :p1)]on:person/friendalso changed frozen answers) checked and rejected: every changed hash is the:person/selfquery, and:person/friendstores keywords. Its test-gap notes (UUID keywords,or, sets) are added.Backport to
mainfollows as its own PR; docs site PR to follow.🤖 Generated with Claude Code
https://claude.ai/code/session_01Urda7FD9CYYoxdeGGJa11x