tonsky / datascript

Immutable database and Datalog query engine for Clojure, ClojureScript and JS
Eclipse Public License 1.0
5.45k stars 304 forks source link

Regression in 1.6.4: unbound vars not filtered #469

Closed mainej closed 4 months ago

mainej commented 4 months ago

While drafting #468, I noticed another regression. The two problems are quite likely related, but I'm submitting this one separately so I can explain it in isolation.

Consider the same query as in #468, but with the following edit to the or-join:

(or-join
 [?x ?y]
 (and [?x :parent ?z]
      [?z :parent ?y])
- [?y :parent ?x])
+ [?x :parent ?y])

In 1.6.3 this produces:

(["alice" #{[1 3] [1 2]}] 
 ["bob" #{[2 3]}]
 ["clara" #{}])

In 1.6.4 it produces:

(["alice" #{[1 3] [1 2]}]
 ["bob" #{[2 3]}] 
 ["clara" #{[3 nil]}])

It's very surprising to see a nil in the output of a query!

tonsky commented 4 months ago

Hopefully fixed in 1.6.5