datomic

Ask questions on the official Q&A site at https://ask.datomic.com!
Pragyan Tripathi 2021-05-16T11:23:22.115900Z

I figured out a way to use refs in my schema to solve my problem... Thanks 🙂

favila 2021-05-16T16:56:50.118200Z

Your destructuring doesn’t make sense to me. What is ?e2 supposed to be?

favila 2021-05-16T16:58:28.120200Z

The only choices you have for destructuring are to take the value as a whole unchanged, to take it as a collection of single items, or to take it as a collection of relations.

favila 2021-05-16T17:01:24.123800Z

I think you either want args [db [ref1 ref2]] :in [$ [?e ...]] or args [db [ref1][ref2]] :in [$ [?e...] [?e2 ...]]

favila 2021-05-16T17:02:51.125800Z

You are doing args [db [ref1 ref2]] :in [$ [[?e ...][?e2 ...]]]

favila 2021-05-16T17:03:27.126700Z

The query parser isn’t catching this as a syntax error but it should

2021-05-16T17:42:48.126900Z

You're right; when i initially reported this issue I used

[db [ref1][ref2]] :in [$ [?e...] [?e2 ...]]
instead of the syntax in the repro. Let me get an example ready.

2021-05-16T18:04:03.127100Z

I updated my example to be more in line with my original report. Sorry for the noise 😅

joshkh 2021-05-16T21:44:45.138Z

maybe someone can help me solve a mystery. i'm replaying my transaction log into a new database and ran into a snag at this datom, which is adding a fact about a reference to entity 69269232556469022. the weird thing is that 69269232556469022 hasn't appeared in the transaction log up until now

(seq (d/tx-range conn {:start 64289 :end 64290}))
=>
({:t    64289,
  :data [...
         #datom[67580382696205085 715 69269232556469022 13194139597601 true]
         ...]})
and when i query its history it seems to have never existed
(d/q '{:find  [?mystery ?a ?v]
       :in    [$ ?mystery]
       :where [[?mystery ?a ?v]]}
     (d/history (d/db conn))
     69269232556469022) 
=> []
attribute 715 is a standard reference with history enabled by default (though i don't think that would make a difference here, since it's the entity itself that seems to be missing) any idea what's going on?

Joe Lane 2021-05-16T22:21:05.138800Z

What is attr 715?

joshkh 2021-05-17T09:03:43.153900Z

i've changed the ident name of the attribute below, but other than that it looks like this

#:db{:id          715,
     :ident       :album/artist,
     :valueType   #:db{:id 20, :ident :db.type/ref},
     :cardinality #:db{:id 35, :ident :db.cardinality/one},
     :doc         "A reference to the artist of an album"}

joshkh 2021-05-17T09:06:21.154100Z

i don't know if it's related but 715 in my original post would have likely been pointing to a composite tuple entity with a uniqueness constraint by identity

Joe Lane 2021-05-17T14:31:08.155600Z

In the old or the new db?

joshkh 2021-05-17T14:33:16.155800Z

this is all in the old db before we get to the part of replaying the tx in the new db

Joe Lane 2021-05-17T14:43:18.156200Z

@joshkh Is this on dev-local, cloud, on-prem? Can you send back a report of running: 1. (d/pull (d/db conn) '[*] 69269232556469022) 2. (d/pull (d/as-of (d/db conn) 64288) '[*] 69269232556469022) 3. (d/pull (d/as-of (d/db conn) 64289) '[*] 69269232556469022) 4. (d/pull (d/as-of (d/db conn) 64290) '[*] 69269232556469022) 5. (d/pull (d/as-of (d/db conn) 64291) '[*] 69269232556469022) You can dm me or send this to support.