Repository navigation
fix(query): expression = / != equate a keyword with a ref to its entity (#744) — backport - #749
Merged
Merged
Conversation
…ty (#744) — backport Backport of the v3 fix. Patterns and joins 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. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Urda7FD9CYYoxdeGGJa11x
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
This was referenced Oct 24, 2026
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
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.
Backport of #748 (v3) for #744, a data-integrity issue under the support policy. #744 stays open until the v2.x patch with this fix is published.
Change
eval_binop(src/query/datalog/executor.rs) compares=/!=withexpr_eq: structural equality, except that a keyword equals a ref to the entityedn_to_entity_idderives from it, as patterns and joins already compare them. With?gbound to a ref to:bob's entity,[(= ?g :bob)]now keeps the row and[(!= ?g :bob)]drops it. Ordering comparisons on a keyword or a ref stay a type mismatch.Tests
New
tests/keyword_ref_expression_test.rs(4 tests): both operand orders, a keyword constant and value,!=, a binding expression, a boundVal(Ref), a rule body,not, anorbranch, a UUID-named keyword; in memory, after a checkpoint and after reopen. They fail onmainwithout the fix.Full suite 1,325 passed (Windows CI hit the pre-existing flaky #750, passed on rerun) / 9 ignored;
cargo fmt --checkandcargo clippy --all-features -- -D warningsclean. CHANGELOG[Unreleased],docs/TEST_COVERAGE.mdand theCLAUDE.mdcount updated.🤖 Generated with Claude Code
https://claude.ai/code/session_01Urda7FD9CYYoxdeGGJa11x