Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rules - Required bindings doesn't evaluate correctly #441

Open
rjsheperd opened this issue Dec 15, 2022 · 1 comment
Open

Rules - Required bindings doesn't evaluate correctly #441

rjsheperd opened this issue Dec 15, 2022 · 1 comment

Comments

@rjsheperd
Copy link

rjsheperd commented Dec 15, 2022

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.

@tonsky
Copy link
Owner

tonsky commented Dec 15, 2022

I don’t think we support this. There’s some work in the parser but it’s not used in current query impl. There are no tests on this either

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants