Datomic Console NOT parse not-clause correctly

Datomic Console NOT parse not-clause correctly, e.g. query

[:find (count ?e)
 :where
 [?e :artist/name ?name]
 (not [(clojure.string/includes? ?name "Foo")])
]

will be parsed to:

[:find (count ?e)
 :where
 [?e :artist/name ?name]
 ["not" [(clojure.string/includes? ?name "Foo")]]
]

which is invalid.

Datomic Console query parse bug not-clause

Thought use following query is OK:

[:find (count ?e)
 :where
 [?e :artist/name ?name]
 [(clojure.string/includes? ?name "Foo") ?test]
 [(not ?test)]
]

but the :query-stats shows these two queries is different, first query with only 1 clause:

(-> {:query       '[:find (count ?e)
                   :where
                   [?e :artist/name ?name]
                   (not [(clojure.string/includes? ?name "Foo")])]
     :args        [(d/db mbrainz-conn)]
     :query-stats true}
    (d/query)
    (get :query-stats)
    (clojure.pprint/pprint))

=>

{:query
 [:find
  (count ?e)
  :where
  [?e :artist/name ?name]
  (not [(clojure.string/includes? ?name "Foo")])],
 :phases
 [{:sched
   (([?e :artist/name ?name]
     [((clojure.core/fn
        [?name]
        (not (and (clojure.string/includes? ?name "Foo"))))
       ?name)])),
   :clauses
   [{:clause [?e :artist/name ?name],
     :rows-in 0,
     :rows-out 4596,
     :binds-in (),
     :binds-out [?e ?name],
     :preds
     ([((clojure.core/fn
         [?name]
         (not (and (clojure.string/includes? ?name "Foo"))))
        ?name)]),
     :expansion 4596,
     :warnings {:unbound-vars #{?e ?name}}}]}]}
nil

and the second query with 2 clause:

(-> {:query       '[:find (count ?e)
       :where
       [?e :artist/name ?name]
       [(clojure.string/includes? ?name "Foo") ?test]
       [(not ?test)]]
     :args        [(d/db mbrainz-conn)]
     :query-stats true}
    (d/query)
    (get :query-stats)
    (clojure.pprint/pprint))

=>

{:query
 [:find
  (count ?e)
  :where
  [?e :artist/name ?name]
  [(clojure.string/includes? ?name "Foo") ?test]
  [(not ?test)]],
 :phases
 [{:sched
   (([?e :artist/name ?name]
     [(clojure.string/includes? ?name "Foo") ?test]
     [(not ?test)])),
   :clauses
   [{:clause [?e :artist/name ?name],
     :rows-in 0,
     :rows-out 4601,
     :binds-in (),
     :binds-out [?e ?name],
     :expansion 4601,
     :warnings {:unbound-vars #{?e ?name}}}
    {:clause [(clojure.string/includes? ?name "Foo") ?test],
     :rows-in 4601,
     :rows-out 4596,
     :binds-in [?e ?name],
     :binds-out [?test ?e],
     :preds ([(not ?test)])}]}]}
nil

more info

Datomic Console version: datomic-pro-1.0.6735

1 Like