Welcome! Please see the About page for a little more info on how this works.

0 votes
in Client API by

Hello Clojurians,

According to Datomic client API the (with db tx-data) allows to make queries on a database with additionnal facts without asserting them. Afaik, it's also known as "what-if" query.

The docs says that the tx-data should be exactly the sam as in a transact.

But on my machine, this works:

(d/transact conn {:tx-data [{:token/color :blue}]})        

But this doesn't:

(d/q '[:find (count ?e1)                             
       :in $                                                                                                                                         
       :where [?e1 :token/color :grey]]                                                                                                 
     (d/with (d/db conn) {:tx-data [{:token/color :grey}]})) 

With this error:

  Show: Project-Only All                                                                                                                                                                                             
  Hide: Clojure Java REPL Tooling Duplicates  (11 frames hidden)                                                                                                                                                     
                                                                                                                                                                                                                     
1. Unhandled clojure.lang.ExceptionInfo                                                                                                                                                                              
   Datomic Client Exception                                                                                                                                                                                          
   {:cognitect.anomalies/category :cognitect.anomalies/incorrect,                                                                                                                                                    
    :http-result                                                                                                                                                                                                     
    {:status 400,                                                                                                                                                                                                    
     :headers                                                                                                                                                                                                        
     {"server" "Jetty(9.4.27.v20200227)",                                                                                                                                                                            
      "content-length" "247",                                                                                                                                                                                        
      "date" "Sun, 01 Nov 2020 16:13:07 GMT",                                                                                                                                                                        
      "content-type" "application/transit+msgpack"},                                                                                                                                                                 
     :body nil}}                                                                                                                                                                                                     
                 async.clj:   58  datomic.client.api.async/ares                                                                                                                                                      
                 async.clj:   54  datomic.client.api.async/ares                                                                                                                                                      
                  sync.clj:  120  datomic.client.api.sync/eval27181/fn                                                                                                                                               
             protocols.clj:  126  datomic.client.api.protocols/fn/G                                                                                                                                                  
                   api.clj:  363  datomic.client.api/with                                                                                                                                                            
                   api.clj:  353  datomic.client.api/with                                                                                                                                                            
                      REPL:  275  four.core/eval28597                                                                                                                                                                
                  core.clj: 3214  clojure.core/eval                                                                                                                                                                  
                  core.clj: 3210  clojure.core/eval                                                                                                                                                                  
                  main.clj:  437  clojure.main/repl/read-eval-print/fn                                                                                                                                               
                  main.clj:  458  clojure.main/repl/fn                                                                                                                                                               
                  main.clj:  368  clojure.main/repl                                                                                                                                                                  
               RestFn.java: 1523  clojure.lang.RestFn/invoke                                                                                                                                                         
                  AFn.java:   22  clojure.lang.AFn/run                                                                                                                                                               
                  AFn.java:   22  clojure.lang.AFn/run                                                                                                                                                               
               Thread.java:  844  java.lang.Thread/run                                                                                                                                                               
     

Any clue ?

Please log in or register to answer this question.

...