Fork me on GitHub
#datomic
<
2015-11-13
>
sjol05:11:07

Why can I not set the eid for an entity? doing

(d/transact conn [{:db/id 175921860454230 :user/name "test_new" }])
throws an error
[...]:cause ":db.error/invalid-entity-id Invalid entity id: 175921860454230"[...]
can't I set the eid?

robert-stuttaford06:11:08

is the id already in storage? if not, you need to use d/tempid to create a temporary id for it to convert to an in-storage one

robert-stuttaford06:11:20

you can’t make eids directly by yourself

nha12:11:54

@raywillig: Did not know that, it could come in handy.

Lambda/Sierra14:11:01

@sjol: No, you cannot set EIDs. The transactor creates & manages EIDs to support efficient indexing and storage. Transactions may refer to existing entity IDs, but must use d/tempid to create new entities.

zirmite15:11:19

I’m trying to import messaging data and set :db/txImport to the timestamp for each message. I’m running into time conflicts when I try a second import with overlapping timestamps. do I have to import in strict timestamp order? i.e., import all messages in a set of transactions ordered by timestamp.

marshall15:11:54

@zirmite: That’s correct. http://docs.datomic.com/best-practices.html#set-txinstant-on-imports "note that you must choose a :db/txInstant value that is not older than any existing transaction's :db/txInstant value and not newer than the transactor's clock time"

zirmite15:11:21

got it, thanks!

zirmite15:11:09

i had read that passage multiple times but only after asking my question here did it really sink in

marshall15:11:51

rubber duck FTW

ljosa18:11:49

Are there any limitations on the size of a pull pattern? I just ran into a bug where I had listed all the attributes I needed, and some where not returned. When I instead put * in the pattern, it worked.

marshall19:11:21

@ljosa: What version of Datomic are you using?

marshall19:11:45

0.0.5198 release notes included: * Fixed bug where the pull API did not always return all explicit reverse references.

ljosa19:11:22

0.9.5153, it looks like

Lambda/Sierra19:11:03

I would also check for something simple but easy-to-miss like misspelled attribute names.

ljosa19:11:17

I wish I had a cleaner example, but here I add one attribute and lose another:

> (keys (first (d/q '[:find [(pull ?g [:group/docId
                                                         :group/blocked_psns 
                                                         :group/keywords :group/negative_phrases :group/negative_urls :group/negative_domains :group/psns :group/topic :group/type :group/url_prefix :group/verticals
                                                         {:group/campaign [*]}
                                                         {:creative/_groups [*]}]) ...] :where [?g :group/docId "560d4087090adba02ce7d98e"]] (d/db conn))))
=> (:group/docId :group/verticals :group/type :group/keywords :group/blocked_psns :group/topic :group/campaign :creative/_groups)
^ So far so good, :creative/_groups is there. Now let's add :group/cpc to the pull form:
> (keys (first (d/q '[:find [(pull ?g [:group/docId
                                                         :group/blocked_psns :group/cpc 
                                                         :group/keywords :group/negative_phrases :group/negative_urls :group/negative_domains :group/psns :group/topic :group/type :group/url_prefix :group/verticals
                                                         {:group/campaign [*]}
                                                         {:creative/_groups [*]}]) ...] :where [?g :group/docId "560d4087090adba02ce7d98e"]] (d/db conn))))
=> (:group/docId :group/verticals :group/type :group/keywords :group/blocked_psns :group/topic :group/campaign :group/cpc)

ljosa19:11:01

^ notice that :creative/_groups disappeared when we added :group:cpc

Lambda/Sierra19:11:46

Ah, that's a reverse reference, so it looks like the bugfix @marshall just mentioned may be it.

ljosa19:11:21

great, I'll try that

marshall19:11:30

@ljosa: Yeah, that is the issue we saw with that bugfix

ljosa19:11:51

yes, can confirm that upgrading to 0.9. 5198 fixed it. thanks, @marshall and @stuartsierra!

marshall20:11:00

Glad to hear it @ljosa