Skip to content

Rules - Required bindings doesn't evaluate correctly #441

Description

@rjsheperd

Attempting to follow the Datomic Rules with required bindings documentation and discovered this bug in DataScript.

Here's a short example:

 (d/q '[:find ?need
            :in $ % ?name
            :where (needs ?name ?need)]
    '[["george" :wants :foo]
      ["george" :needs :foo]
      ["sally"  :needs :bar]]
    '[[(needs ?name ?need) [?name :needs ?need]]] "george")
;; => #{[:foo]} (expected)

;; Now try with ?name being a required binding by placing it in brackets
;; -- (needs ?name ?need) -> (needs [?name] ?need)

(d/q '[:find ?need
            :in $ % ?name
            :where (needs ?name ?need)]
    '[["george" :wants :foo]
      ["george" :needs :foo]
      ["sally"  :needs :bar]]
    '[[(needs [?name] ?need) [?name :needs ?need]]] "george")
;; => #{[:foo :bar]} (incorrect)

It may be that the required binding version is always evaluating to true.

Activity

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

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions