Fork me on GitHub
#hyperfiddle
<
2024-04-29
>
Absolute Negativity10:04:06

I'm seeing weird behavior with Datomic's query:

(e/server
  (let [db (ee/watch-db db-conn)
        x (dm/q
            '[:find ?e .
              :where [?e :db/ident]]
            db)]
    (log/info :VAR x)
    (log/info :EXPR (dm/q
                      '[:find ?e .
                        :where [?e :db/ident]]
                      db))))
Whenever db changes, I'd see only :EXPR logged. This also happens if I substitute dm/q with dm/entity or dm/pull . Other operations such as dm/datoms produce expected result (with :VAR logged). What is going on?

xificurC10:04:56

if x results to the same value as it was before electric won't re-run the :VAR log call since the arguments to it didn't change. Can that be the case here?

❤️ 1
Absolute Negativity11:04:47

Oh silly me. Yes that's it. Thank you.

Absolute Negativity11:04:53

Looks like it's not the case for the original problem I'm struggling with:

(e/server
  (log/info :arg state/db uid)
  (let [x (some? (seq (d/entity state/db uid)))]
    (log/info :VAR x)
    (log/info :EXPR (some? (seq (d/entity state/db uid))))))
Here I make some transaction and got the following logs:
:arg datomic.db.Db@4d9e0613 17592186201160
:VAR true
:EXPR true

;; after tx

:arg datomic.db.Db@add94f9 17592186201160
:EXPR false
Do you have any idea?

Absolute Negativity11:04:39

Bingo. Thank you so much.

😉 1
s-ol14:04:39

yikes, that's sneaky