Fork me on GitHub
#datomic
<
2017-07-14
>
favila02:07:25

Maybe for larger lists. I've never used it. I never need order over more than ~10 items at a time

isaac11:07:18

Datomic can’t install attribute & functions in one transaction?

cjmurphy13:07:23

If you do a pull on a :db/id and get a number back, then enter that number in the "Entities" tab of the Datomic Console, you would expect to get something back every time. Trouble is I get no response. It seems there's something I don't understand.

jaret14:07:52

@isaac No, you cannot create and then use the attribute in the same transaction.

jaret14:07:08

@cjmurphy can you call d/entity on the id?

isaac14:07:26

I have functions & schemas, I want d/transact in the same transaction, that will throws error. this code will throws

@(d/transact conn (concat schemas functions))
but working while I separates theme
@(d/transact conn schemas)
@(d/transact conn functions)

jaret14:07:10

@isaac Yep, thats exactly what I expect. You cannot create and use the attributes (schema) in the same transaction.

jaret14:07:09

the attributes have to exist to be used.

pbostrom15:07:16

it would be nice if there was an API to start a peer server in-memory/in-process to simplify testing setup/teardown

hmaurer15:07:16

there is also the in-memory datomic connection, e.g. (d/connect "datomic:")

pbostrom15:07:20

no, that uses the peer API, I want to write some tests using the client API without having to kick off a separate peer server process

cjmurphy15:07:35

@jaret: When I call d/entity on it I get back: #:db{:id 17592186045473}

cjmurphy16:07:29

Calling (d/pull db '[*] id), where id is 17592186045473, which is of course the original number, gives me a hash-map that has all the attributes I would expect in it.

isaac16:07:02

@jaret thanks, I resolved

cjmurphy16:07:45

Oh shivers - I did it again and it worked. Just needed to refresh the browser.

cjmurphy17:07:56

I am trying to work with idents, doing this: (d/pull db '[*] [:account/name "bank-fee"]), and get the error message "Attribute values not unique: :account/name". Not sure what that means. There is only one :account/name called "bank-fee", and in the schema I marked :account/name to be :indexed. Is there something else I can do to make my little pull statement work, or am I going about it wrong?

schmee17:07:58

@cjmurphy your entity needs to be unique for lookup refs to work: http://docs.datomic.com/identity.html#lookup-refs

schmee17:07:31

i.e :db/unique instead of :db/index on the schema attribute

cjmurphy17:07:54

Thanks @schmee (and @jaret from before). I'm using the YuppieChef thing, so I think that translates to :unique-identity - will give it a try.

favila17:07:32

:unique-value and :unique-identity are different @cjmurphy but both will allow lookup refs

cjmurphy17:07:28

I think I'll go for :unique-value then...

cjmurphy17:07:10

Hmm - they both somehow seem to stop upserting, which I'm relying on when importing data.

cjmurphy17:07:53

"Two datoms in the same transaction conflict".

schmee17:07:51

hint: you want :db.unique/identity for upserts

cjmurphy18:07:49

Yes :unique-identity (using Yuppiechef) gets me past that error on that attribute. And furthermore allows me to d/pull using an ident. Thanks @schmee simple_smile

hmaurer20:07:06

Is it necessary to backup an S3 Datomic backup file? e.g. is it possible for datomic’s backup process to corrupt a backup file due to malfunction?

schmee22:07:43

can you not call Java functions in a query from a Datomic client?

schmee22:07:32

or Clojure fns…?

schmee22:07:35

kleinheit.datomic.impl=> (a/<!! (c/q conn {:query '[:find ?e :where [?e :advertiser/advertiser ?v] [(subs ?v 0 1) "a"]] :args [(c/db conn)]}))
{:dbs [{:database-id "datomic:"
        :history false
        :next-t 2002
        :t 1001}]
 :cognitect.anomalies/category :cognitect.anomalies/incorrect
 :cognitect.anomalies/message "The following forms do not name predicates or fns: (subs)"}

hcarvalhoaves22:07:04

you can, as long as the symbol is available inside the namespace you evaluate the query

hcarvalhoaves22:07:22

ah sorry... Datomic client

hcarvalhoaves22:07:52

I see now. It might not be supported because of the above (the peer is not the same runtime evaluating the query)

hcarvalhoaves22:07:18

in this case I believe you need to the use the peer API

schmee22:07:35

I mean, it makes sense, but it’s crazy that this is not mentioned in the docs

favila22:07:09

try clojure.core/subs

schmee22:07:24

same thing

favila22:07:39

wait that clause is wrong

favila22:07:27

[(subs ?v 0 1) "a"] works?

favila22:07:58

don't you have to bind it then compare?

favila22:07:18

[(subs ?v 0 1) ?a][(= ?a "a")]?

favila22:07:43

you may still not be able to use subs via the client api, but even on the peer api this seems wrong

schmee23:07:16

@U09R86PA4 you are correct!

schmee23:07:31

the modified query works just fine with the Peer API

schmee23:07:56

again, is this not documented or have I just missed it?