Fork me on GitHub
#datomic
<
2017-02-09
>
anmonteiro01:02:43

can someone point me to docs explaining the new tempid behavior?

anmonteiro02:02:18

specifically, I'm trying to figure out which values are allowed in :db/id when annotating transactions

anmonteiro02:02:13

oops, after 30 min looking for it, writing here is what made me find it 🙂 http://docs.datomic.com/transactions.html#outline-container-2-1-1

stijn09:02:02

is there a way to reliably catch 'Non-existing look-up ref' exceptions?

stijn09:02:14

(try
  (d/q
    '[:find ?e
      :in $ ?some
      :where [?some :other/attr ?e]]
    db
    [:some/id (d/squuid)])
  (catch Exception e
    (some-> e .getCause .getCause .getMessage (.startsWith "Cannot resolve key"))))

stijn09:02:21

does not seem like the best way 🙂

rauh09:02:36

@stijn Call d/entid beforehand.

jcf14:02:03

Anyone come across the following error before?

java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.lang.RuntimeException: Can't let qualified name: db/id, compiling:(NO_SOURCE_PATH:0:0)
	at datomic.promise$throw_executionexception_if_throwable.invoke(promise.clj:10)
	at datomic.promise$settable_future$reify__6755.deref(promise.clj:54)
	at clojure.core$deref.invokeStatic(core.clj:2228)
	at clojure.core$deref.invoke(core.clj:2214)
I'm not using db/id in my code anywhere. This is inside a Manifold deferred BTW.

favila14:02:40

someone's trying to do (let [db/id x]). Never seen before

jcf14:02:02

@favila pretty sure it's not me. 🙂

favila14:02:24

look for macros?

favila14:02:44

or maybe a map needs some wrapping?

val_waeselynck14:02:59

@favila couldn't it be a {:keys [db/id]} destructuring ?

jcf14:02:07

I have a macro for measuring time taken, but removed it to make sure that's not it.

jcf14:02:19

@val_waeselynck that would make sense if it were in a macro.

favila14:02:29

@val_waeselynck ah, it could be, but on an older clojure

val_waeselynck14:02:41

yeah that's what I was thinking

jcf14:02:46

But I'm not doing

(defmacro blah []
  `(let [{:keys [db/id]} (d/transact conn ...)))
anywhere.

val_waeselynck14:02:25

search Datomic's source code... oh wait, you can't.

favila14:02:28

are you transacting?

favila14:02:36

when you hit this error?

favila14:02:16

could you perchance be doing something like (d/transact conn {:my "map"})

favila14:02:26

i.e. forgetting to wrap in vector?

jcf14:02:51

(if (seq txes)
     (let [{:keys [db-after]} @(datomic/transact datomic txes)]
       ;; ...
      (datomic/entity datomic db-after (:db/id task)))
    ;; ...
  )

jcf14:02:10

It's something like that with irrelevant bits removed. I'll sniff around the txes to make sure they're valid.

jcf14:02:48

[{:db/id 17592186045447, :task/state :task.state/failed,
   :task/next-run #inst "2017-02-10T17:09:02.353-00:00"}
  [:inc-attr 17592186045447 :task/retries]]

jcf14:02:59

Txes are a vector of a map and a db/fn.

favila14:02:31

perhaps there's something in the impl of :inc-attr

jcf14:02:40

Oh! That could be it!!

favila14:02:58

try to invoke it directly

jcf14:02:08

{:db/id #db/id [:db.part/user]
 :db/ident :inc-attr
 :db/fn #db/fn
 {:lang "clojure"
  :params [db lookup-ref attr]
  :code
  (let [{:keys [db/id] :as ent} (d/entity db lookup-ref)]
    [[:db/add id attr (-> ent (get attr 0) inc)]])}}

jcf14:02:18

I have a test for that db/fn mind.

favila14:02:26

ah there it is

jcf14:02:45

Oh yeah. Parens wrong.

jcf14:02:23

@favila I must be missing something. Where's the problem with that db/fn?

favila14:02:46

looks good to me, unless it runs on an older clojure

favila14:02:10

but it's unlikely the transactor's classpath is being messed with

val_waeselynck14:02:41

@jcf does it work when you run the function locally ?

val_waeselynck14:02:04

(e.g in a d/with)

favila14:02:18

(d/invoke db :inc-attr db 17592186045447 :task/retries)

favila14:02:23

will be more direct

jcf14:02:38

@val_waeselynck I have a couple of tests that use the function, but with an in-memory database.

val_waeselynck14:02:00

@jcf and so, do those work ?

jcf14:02:07

Yes 😄

val_waeselynck14:02:11

or do they throw the error

val_waeselynck14:02:17

ok that narrows the scope

val_waeselynck14:02:46

I'm guessing either the transactor runs an older version of Clojure, or there's a problem in the serialization of the function code

jcf14:02:11

Just written this test, and it passes:

(deftest ^:integration t-inc-attr
  (t/with-system [{:keys [datomic]} (test.datomic/new-datomic-system)]
    (let [db (sut/db datomic)]
      (is (= [[:db/add 17592186045447 :task/retries 1]]
             (d/invoke db :inc-attr db 17592186045447 :task/retries))))))

jcf14:02:49

I'll double check the version of Clojure on the transactor, but pretty sure it'll be the same everywhere.

jcf14:02:34

Transactor's running Clojure 1.8 too.

val_waeselynck14:02:22

@jcf does it work if you rewrie the function to not use destructuring ?

jcf14:02:39

Removing the destructuring from the Transactor fixed it.

jcf14:02:03

Strange. We must not be running the version of Clojure I thought, or maybe there's a bug fix we're missing.

jcf14:02:23

Thanks for the help chaps.

val_waeselynck15:02:48

@jcf you can write a transaction function which returns the current Clojure version (in an exception)

val_waeselynck15:02:18

I mean the one running in the Transactor.

jcf15:02:39

That's one way to do it. I checked the transaction-pom.xml and found Clojure 1.6. I've recommended an upgrade.

favila15:02:47

@jcf look at the files in lib/ in the txor distribution

favila15:02:09

unless you are adding to that classpath, those are what you are getting

favila15:02:27

on the latest transactor, clojure-1.9.0-alpha14 is in use

favila15:02:04

are you using a very old transactor? or including jars on the transactor's classpath which may overwrite the clojure libs?

zane19:02:47

What's the right way in Datalog to express that the set of all values bound to a given variable must be equal to the set of all the values bound to another variable?

favila19:02:47

given set is strict subset of other set?

favila19:02:06

or the two sets are exactly equal?

zane23:02:59

@favila: The latter.

zane23:02:07

Also, what is the most appropriate way to ETL data into datomic?

Alex Miller (Clojure team)01:02:56

There was a great talk on this by Stuart Halloway at the Clojure Conj last fall

zane14:02:09

Yeah! Jaret just recommended it to me.