Fork me on GitHub
#datomic
<
2017-05-06
>
ezmiller7711:05:05

I have a schema that includes an attribute :a/metadata, which in turn can hold an attribute :b/tags. And :b/tags takes a :tag. :a/metadata and :b/tags are refs with the component option set to true. If I pull an entity containing these attributes, however, I am getting some incongruent results between an in-memory db and a db setup using the transcator. If I do it using an in-memory db, the tags are pulled completely, but if I do it with the dev db using the transactor, I only get the :db/id for the tags. I'm trying to understand why this might be happening. One thought I had is that the dev db is slower, and that the transaction has somehow not yet completed, so that even though I'm pulling with the version of the db that is returned by the transaction, that those value aren't yet saved... Anyone have any thoughts?

val_waeselynck12:05:55

@ezmiller77 can you show us the pattern you use for pulling?

ezmiller7712:05:45

Sure. Basically, I do the transaction. Then from the result of the transaction I get :db-after so that I'm sure to be using the correct version of the db. I then just do use the pull api:

ezmiller7712:05:13

(d/pull db-after '[*] [:arb/id id])

ezmiller7712:05:20

(The attribute shown there has a different name than waht `i wrote above, as I was just trying to simplify...)

val_waeselynck12:05:22

I see. I'm not sure I can picture the entity diagram though. Could you show some example data (i.e a few datoms with these attributes) ?

val_waeselynck12:05:14

and also what the output of the pull looks like ?

ezmiller7712:05:18

So this is correct pull output that shows what you are asking for I think:

{:db/id 17592186045421,
 :arb/id #uuid "590dc5a2-00e1-4a5b-8901-1fbc62c0dbc9",
 :arb/value
 [{:db/id 17592186045428,
   :arb/value [{:db/id 17592186045430, :content/text "Title"}],
   :arb/metadata [{:db/id 17592186045429, :metadata/html-tag :h1}]}
  {:db/id 17592186045431,
   :arb/value [{:db/id 17592186045433, :content/text "Paragraph"}],
   :arb/metadata [{:db/id 17592186045432, :metadata/html-tag :p}]}],
 :arb/metadata
 [{:db/id 17592186045422, :metadata/html-tag :div}
  {:db/id 17592186045423, :metadata/title "Untitled"}
  {:db/id 17592186045424, :metadata/doctype {:db/id 17592186045418}}
  {:db/id 17592186045425,
   :metadata/tags
   [{:db/id 17592186045426, :metadata/tag :tag1}
    {:db/id 17592186045427, :metadata/tag :tag2}]}]}

ezmiller7712:05:28

This is an example of the pull result where the tags aren't recovered:

{:db/id 17592186046255,
 :arb/id #uuid "590dc664-0ee1-4d47-b1ec-eeb332eeace9",
 :arb/value
 [{:db/id 17592186046260,
   :arb/value [{:db/id 17592186046262, :content/text "A title "}],
   :arb/metadata [{:db/id 17592186046261, :metadata/html-tag :p}]}
  {:db/id 17592186046263,
   :arb/value [{:db/id 17592186046265, :content/text "Paragraph"}],
   :arb/metadata [{:db/id 17592186046264, :metadata/html-tag :p}]}],
 :arb/metadata
 [{:db/id 17592186046256, :metadata/html-tag :div}
  {:db/id 17592186046257, :metadata/title "A title"}
  {:db/id 17592186046258, :metadata/doctype {:db/id 17592186045418}}
  {:db/id 17592186046259, :metadata/tags [{:db/id 17592186045417}]}]}

val_waeselynck12:05:12

hmm I see. Weird

val_waeselynck12:05:31

First thing I would check is that the attributes are actually the same in both dbs - by calling e.g (datomic.api/attribute db :metadata/tag) for both dbs

ezmiller7712:05:03

That makes sense. Will try that. Thanks.

ezmiller7715:05:41

@val_waeselynck I suspect the problem I am having is related to a limitation of pull related to enums: https://groups.google.com/forum/#!topic/datomic/WBLEqNH6RtE