Fork me on GitHub
#datomic
<
2022-05-07
>
Benjamin16:05:40

level 2

=== Incorrect Query Response ===
[[["Miguel" "Dvd Rom"]]
 [["J. R." "Token"]]
 [["E. L." "Mainframe"]]
 [["Perry" "Farrell"]]
 [["Charles" "Diskens"]]
 [["Miles" "Dyson"]]
 [["Napoleon" "Desktop"]] 
 [["Segfault" "Larsson"]] 
 [["Kim" "K"]]]
=== Expected Query Response ===
[[["Miguel" "Dvd Rom"]]
 [["J. R." "Token"]]
 [["E. L." "Mainframe"]]
 [["Charles" "Diskens"]]
 [["Perry" "Farrell"]]
 [["Miles" "Dyson"]]
 [["Napoleon" "Desktop"]] 
 [["Segfault" "Larsson"]] 
 [["Kim" "K"]]]
my answer:
(ns level-2
  (:require
    [datomic.client.api :as d]
    [max-datom.connections :refer [db]]))

(d/q '[:find ?n
       :where [_ :book/author ?v] 
       [?v :author/first+last-name ?n]] db)

Benjamin17:05:02

ah now I see the ordering is different

Jarrod Taylor (Clojure team)17:05:18

The query you are running isn’t the one expected (although it does produce very similar results 🙂) You are taking the value of :book/author ?v and using it as the entity to unify :author/first+last-name on which is probably not what you want for the answer. All you need here is:

(d/q '[:find ?v
       :where [_ :author/first+last-name ?v]] db)

Benjamin08:05:35

ah I see thanks