Fork me on GitHub
#datascript
<
2017-04-05
>
misha12:04:50

is there an enforced order of the same-rules invocation? trying to add default value to the multy-definitions rule, but default some times gets returned before all the rule options are exhausted

misha12:04:22

using get-else within multi-definition rule would always return after 1st rule definition execution

misha13:04:52

(let [rules '[[(rule-foo ?e ?v) [?e :foo/bar ?v]]
              [(rule-foo ?e ?v) [?e :foo/baz ?v]]
              [(rule-foo ?e ?v) [(ground :default) ?v]]]
      conn (ds/create-conn)]
  (ds/transact! conn [{:foo/bar "bar"}
                      {:foo/baz "baz"}
                      {:foo/qux "qux"}])
  (ds/q '[:find ?e ?v
          :in $ %
          :where
          [?e] ;; include all entities
          (rule-foo ?e ?v)]
    @conn rules))

=>>
#{[1 :default] [1 "bar"] [2 :default] [2 "baz"] [3 :default]}
how to avoid groupping-by/filtering result and get this right away?
#{[1 "bar"] [2 "baz"] [3 :default]}