Fork me on GitHub
Jakub Holý (HolyJak)21:03:58

There seems to be a bug 🐛 in the impl of transitive attribute queries. The last example from the doesn’t work:

(let [conn (d/connect "asami:")]
    @(d/transact conn {:tx-data [{:db/id -1 :name "Washington Monument"}
                                 {:db/id -2 :name "National Mall"}
                                 {:db/id -3 :name "Washington, DC"}
                                 {:db/id -4 :name "USA"}
                                 {:db/id -5 :name "Earth"}
                                 {:db/id -6 :name "Solar System"}
                                 {:db/id -7 :name "Orion-Cygnus Arm"}
                                 {:db/id -8 :name "Milky Way Galaxy"}
                                 {:db/id -9 :db/ident 9 :name "Arlington"}
                                 {:db/id -10 :db/ident 10 :name "Falls Church"}
                                 [:db/add -1 :is-in -2]
                                 [:db/add -2 :is-in -3]
                                 [:db/add -3 :is-in -4]
                                 [:db/add -4 :is-in -5]
                                 [:db/add -5 :is-in -6]
                                 [:db/add -6 :is-in -7]
                                 [:db/add -7 :is-in -8]
                                 [:db/add -9 :neighbor -3]
                                 [:db/add -10 :neighbor -9]]})
    (d/q '[:find ?name :where [?e :name "Falls Church"][?e ?a* ?e2][?e2 :name ?name]] (d/db conn)))
; =>
; Execution error (ExceptionInfo) at asami.common-index/eval9492$fn (common_index.cljc:346).
; Unable to do transitive closure with nothing bound
; ex-data: `{:args [?e ?a ?e2]}
` The ?e should have been bound due to the preceding rule [?e :name "Falls Church"] but the code does not seem to understand that. Perhaps because the get-transitive-from-index defmethod is not aware of the context it is called in? (Latest Asami 2.3.3.)