D/with not working inside tx fn in dev-local

It seems d/with should work inside tx fn, but I’m getting an exception whenever I try it in dev-local:

                             datomic.client.api/with                  api.clj:  363
               datomic.client.api.protocols/fn/G            protocols.clj:  126
                        datomic.core.local-db/fn             local_db.clj:   67
                         datomic.core.db.Db/with                   db.clj: 2164
                         datomic.core.db/with-tx                   db.clj: 3369
                datomic.core.db/add-ensured-data                   db.clj: 3352
                      datomic.core.db.Db/addData                   db.clj: 2322
                               clojure.core/conj                 core.clj:   85
                                             ...                               
          datomic.dev-local.btindex.BTIndex/cons              btindex.clj:  281
                                             ...                               
      datomic.dev-local.local-log.LocalLog/valAt            local_log.clj:   56
         datomic.dev-local.tx/datom-lookup-valfn                   tx.clj:  397
java.lang.ClassCastException: class datomic.core.db.Datum cannot be cast to class 
java.lang.Number (datomic.core.db.Datum is in unnamed module of loader 'app'; 
java.lang.Number is in module java.base of loader 'bootstrap')

Should d/with in tx fn be supported in dev-local?

d/with should work in dev-local, but the database must from from a call to d/with-db. Where is your db coming from?

It is the db provided by d/transact when it calls my tx fn.

I’m calling d/transact with and then calling d/with on the db given as the first arg to my custom transaction function.

Just to be absolutely explicit for future readers’s sake:

    (defn some-tx-fn [current-db & tx-args]
      ,,,
      (d/with (d/with-db current-db) {:tx-data [,,,]})
      ,,,
      )

(I guess; haven’t actually tried it yet, but I used with-db outside of transactions a lot.)

d/with-db requires a connection, I’m calling d/with directly on the current-db that is provided to the transaction function. That works when deployed to Ions, but doesn’t work in dev-local.

Calling d/with inside a transaction function is not currently supported in Datomic Cloud, and the fact that it “works” in ions might change at any time.

That said, we are happy to look at supporting this in the future and would love to know anything you are willing to share about your use case.

That is very worrisome to me, as this thread lead me to believe that it should work as there was a specific bugfifx related to it D/with not working inside tx fn

It is very good functionality to have, as many domain level enforcements are handy to encode as “do speculative tx and check some query results are as expected”. Hopefully this functionality isn’t taken away, it would cause problems for me at least.