8000 An expression = / != does not equate a keyword with a ref to the entity it names · Issue #744 · project-minigraf/minigraf · GitHub
[go: up one dir, main page]

Skip to content

An expression = / != does not equate a keyword with a ref to the entity it names #744

Closed

Description

@adityamukho

Summary

Patterns and joins treat a keyword constant as equal to a ref to the entity it names (:bob ≡ #uuid "<uuid5 of :bob>"). The comparison expressions = and != don't, so the same question gets different answers depending on how the query is written. The wrong answer comes back silently.

Repro

Verified on main (v2.0.10 line, origin/main) and on v3 (0f7c66c0), with the same answers on both:

(transact [[:alice :ref/friend #uuid "<uuid5 of :bob>"]   ; a ref to :bob's entity
           [:carol :kw/friend :bob]])                       ; a keyword value

(query [:find ?x :where [?x :ref/friend :bob]])                        ; 1 row  (pattern constant: equal)
(query [:find ?x :where [?y :ref/friend ?g] [?x :kw/friend ?g]])        ; 1 row  (join on ?g: equal)
(query [:find ?x :where [?x :ref/friend ?g] [(= ?g :bob)]])            ; 0 rows (expression: not equal)
(query [:find ?x :where [?x :ref/friend ?g] [(!= ?g :bob)]])           ; 1 row  (expression: not equal)

The last two should give 1 and 0 rows, matching the pattern and the join.

Cause

The engine's JoinKey (query/engine/join.rs) makes a keyword equal to a ref to the entity it names, for scans, joins, not bodies (#546) and or branches (#637). Expression evaluation (eval_expr, BinOp::Eq/Neq) compares the two Values directly, and Value::Keyword ≠ Value::Ref.

A related gap: an expression can't take a #uuid literal at all ([(= ?g #uuid "...")] is PRS-070), so in query text the keyword is the only way to compare a ref value to a constant. A prepared query can bind Val(Ref) (#181).

Fix direction

Make = and != compare as joins do: a keyword equals a ref to the entity it names. Whether </> on a keyword and a ref should stay a type mismatch needs deciding. A v2.x backport follows the support policy (data-integrity fixes are backported).

Found in passing while testing #181.

🤖 Generated with Claude Code

Activity

  1. added this to the v3.0.0 milestone on Oct 24, 2026
  2. added
    bugSomething isn't working
    known-issueBug present in a published release and not yet fixed in one; listed in the pinned known-issues issue
    on Oct 24, 2026
  3. adityamukho commented on Oct 26, 2026

    @adityamukho
    CollaboratorAuthor

    Fixed in v2.0.11, now published: https://github.com/project-minigraf/minigraf/releases/tag/v2.0.11. The v2.x fix shipped in #749; v3.0.0 is also fixed in #748. Updated the pinned known-issues list (#421).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingdata-integrityData integrit 486B y issueknown-issueBug present in a published release and not yet fixed in one; listed in the pinned known-issues issue

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      0