Fork me on GitHub
#datascript
<
2024-03-07
>
Henrik Larsson11:03:03

I am missing some basic understanding about how to query using datalog in datascript. For example in the following example

(datascript.core/q
   '[:find ?p
     :in [[_ _ ?p] ...]
     :where
     [(and (not (= ?p "A")) (= ?p "B"))]
     [(or (= ?p "A") (= ?p "C"))]]
   [[0 :prn "A"]
    [1 :prn "B"]
    [2 :prn "C"]
    [3 :prn "D"]]) 
I would expect #{["B"] ["C"]} however im getting #{["D"] ["B"] ["A"] ["C"]} What am I missing? Why is not my :where clause restricting the result?

jjttjj14:03:31

You're not using the boolean operators correctly, they should wrap the where clauses, e.g. https://docs.datomic.com/cloud/query/query-data-reference.html#and-example

1