datomic

Ask questions on the official Q&A site at https://ask.datomic.com!
jaret 2021-02-09T00:19:26.175300Z

We have fixed the issue with our docs not working. Big thanks to @audiolabs for fixing everything!

Ben Sless 2021-02-09T09:26:39.176400Z

Hello, I have a question regarding recursive pull syntax - is there a syntax for pulling non component entities?

joshkh 2021-02-09T12:54:47.176600Z

like you implied, component entities pull recursively. for non-component references you can also pull recursively using this syntax: https://docs.datomic.com/cloud/query/query-pull.html#recursive-specifications

val_waeselynck 2021-02-09T14:34:42.177700Z

Am I blind or is there a bug in the Datalog engine?

(d/q '[:find ?e ?a :in $ ?user :where
         [?e ?a ?user]]
    db my-user-lookup-ref)
  => #{}

(vec (d/datoms db :vaet my-user-lookup-ref))
=>
[#datom[17592186084693 110 17592186072420 13194139573588 true]
 #datom[17592186084696 114 17592186072420 13194139573591 true]
 ...
 #datom[17592186072587 213 17592186072420 13194139561484 true]]

val_waeselynck 2021-02-09T14:34:49.177900Z

Should I file an issue?

favila 2021-02-09T14:49:37.178Z

If the attribute cannot be resolved at query “initialization” time, the “v” slot will only match exact matches. It won’t coerce values to an entity id because it doesn’t know that the attribute is a ref until runtime

favila 2021-02-09T14:50:41.178200Z

(d/q '[:find ?e ?a :in $ ?user :where
         [(d/entid $ ?user) ?user-id]
         [?e ?a ?user-id]]
    db my-user-lookup-ref)
try this

favila 2021-02-09T14:51:20.178400Z

or use explicit ?a values visible to the query parser (e.g. with [(ground [:attr1 :attr2]) [?a ...]]

favila 2021-02-09T14:52:10.178600Z

I suspect this is by design for performance, but I’ve never heard cognitect say one way or the other

val_waeselynck 2021-02-09T15:14:41.178800Z

Thanks @favila

val_waeselynck 2021-02-09T15:15:51.179Z

The workaround does the trick, but the behaviour is still quite surprising. If it's not a bug, I think it at least deserves to be documented.

favila 2021-02-09T15:59:01.179200Z

If you’re looking at an :vaet index and don’t know that you want specifically ref :a values, it’s kind of a correctness issue--how will a query engine know it should interpret your V as a lookup ref? Anything you do might be surprising

favila 2021-02-09T15:59:35.179400Z

E.g., suppose there is a literal tuple you want to match, then entid would be wrong

favila 2021-02-09T15:59:52.179600Z

doing both might also be surprising

kenny 2021-02-09T18:43:47.180500Z

Is it okay to pass a db created with datomic.client.api/db to a function in the async client api (e.g., datomic.client.api.async/q)?

micah 2021-02-09T18:58:28.181700Z

“Error communicating with HOST localhost on PORT 4334” with fresh datomic pro install. Works on other computers, just not this particular laptop. Anyone seen this before?

micah 2021-02-09T19:54:36.182100Z

SOLVED: we were running the transactor on Java 15

👀 1
val_waeselynck 2021-02-09T20:53:16.182200Z

I see your point, but I find it debatable 🙂 from a perspective of logical correctness alone, I could imagine the behaviour being different depending on what attribute is considered. More importantly: your objection is a good point, but not an immediately obvious one. Arguably, the mere fact that we are debating it calls for official clarification.

val_waeselynck 2021-02-09T20:53:50.182400Z

Anyway, thanks for taking the time!