Fork me on GitHub
#datomic
<
2017-05-09
>
tomtau09:05:16

Is there a way to set "Access-Control-Allow-Headers" in the bundled REST server?

souenzzo14:05:56

Hello (d/transact conn (some-fn)) throws: clojure.lang.ExceptionInfo: Interceptor Exception: clojure.lang.LazySeq cannot be cast to java.util.Map but (d/transact conn (vec (some-fn))) works. Is is expected? It's a bug? I'm using lazylist in many other places with no problem some-fn is (concat [{:map :form}] (function-that-returns-array-of-db-add))

favila15:05:13

@souenzzo I would inspect the output of (some-fn) carefully

souenzzo15:05:56

How should I inspect?

favila15:05:44

the error is consistent with some inner item not being a vector or map

favila15:05:52

not a problem with the outer level

favila15:05:10

lazy seqs are not a problem on the top level

souenzzo15:05:46

(into [{}] (function...)) works. But I will debug 😉

favila15:05:02

so I am asking you to verify your assumption that (some-fn) is truly a lazy-seq of vectors or maps

favila15:05:35

really that (function-that-returns-array-of-db-add) doesn't have a lazyseq as one of its items

favila15:05:02

oh, could also be that d in d/transact is not peer api?

favila15:05:18

maybe client api is more restrictive. (I have no client api experience)

souenzzo15:05:10

d/transact was "traditional" datomic.

(let [a (concat ..)
b (vec a)]
(println "-----")
    (println (type a))
    (println (class a))
    (println (mapv type a))
    (println (type b))
    (println (class b))
    (println (mapv type b))
    (println "-----")
    a
)
Outputs:
-----
clojure.lang.LazySeq
clojure.lang.LazySeq
[clojure.lang.PersistentArrayMap clojure.lang.PersistentVector clojure.lang.PersistentVector clojure.lang.PersistentVector]
clojure.lang.PersistentVector
clojure.lang.PersistentVector
[clojure.lang.PersistentArrayMap clojure.lang.PersistentVector clojure.lang.PersistentVector clojure.lang.PersistentVector]
-----

favila15:05:36

@souenzzo have you looked at lower depths? what is the problem with just printing it for yourself and looking?

souenzzo15:05:45

(defn function-that-returns-array-of-db-add
[x]
(mapcat (fn [a] [[:db/add a b c]]) x)
)
(internal mapcat fn was really returning a tx-data with a single, write as [[:db/add]]..)

favila15:05:58

ok I'm going to try it too

favila15:05:39

(d/transact c (concat [{:db/doc "1"}] [[:db/add "2" :db/doc "2"]]))
=>
#object[datomic.promise$settable_future$reify__7008
        0x503b2908
        {:status :ready,
         :val {:db-before datomic.db.Db,
               @67615b66 :db-after,
               datomic.db.Db @a034e1ff,
               :tx-data [#datom[13194139534312
                                50
                                #inst"2017-05-09T15:23:29.077-00:00"
                                13194139534312
                                true]
                         #datom[17592186045417 62 "1" 13194139534312 true]
                         #datom[17592186045418 62 "2" 13194139534312 true]],
               :tempids {-9223301668109598144 17592186045417,
                         "2" 17592186045418}}}]

favila15:05:59

that matches my experience

favila15:05:27

(although usually I'm using map or partition)

favila15:05:27

@souenzzo does above give same result for you?

souenzzo15:05:49

I trying to reproduce in a minimal/idolated cenario and cant reproduce too =/

souenzzo15:05:53

I am out of time 😞 sorry. I will use into for now

favila15:05:10

@souenzzo The reason I say look at the output carefully is I am worried that (vec) is masking some problem with your tx nested deep somewhere

favila15:05:48

i.e. that "not getting an exception" != "works"

favila15:05:11

the fact that you can't repro with toy examples makes me nervous for you

souenzzo15:05:12

tx was working (On integration test, everything ok)

csm20:05:55

is anyone running peers in a different AWS region than DynamoDB? Or is that a non-starter?

Lambda/Sierra20:05:53

@csm I would not recommend that. Behavior would be unpredictable with respect to caching and query behavior.

csm20:05:50

I thought as much. Thanks!

erichmond21:05:31

can you restore a database to datomic:ddb-local ?