Fork me on GitHub
#datomic
<
2022-11-23
>
Casey10:11:01

For REPL development when using dev-local with durable data, how can one use attribute predicates? I am getting "Unable to load namespace for..." errors.

favila20:11:36

is the namespace + var of the attribute predicate in your process?

favila20:11:05

You should be able to do (requiring-resolve sym-of-the-attr-predicate)

Mark Sto08:07:50

@U70QFSCG2, hey, were you able to make this work? I now face the same issue, while all namespaces with predicates were required and loaded.

favila14:07:42

You also need to make sure the symbol is fully qualified in the query

favila14:07:31

because queries are typically quoted ' this is easy to overlook

Mark Sto14:07:55

Yeah, I believe everything is fine with the symbol and its quoting. I managed to move a bit further though.

Mark Sto14:07:41

I’ve included datomic/ion-config.edn to my project’s resources because, as it turns out, all such predicates must be explicitly listed as allowed there (even if you’re not developing an Ion).

Mark Sto14:07:13

This helped to resolve the previous error, but I now face another one:

Execution error (ExceptionInfo) at datomic.ion.resolver/anomaly! (resolver.clj:41).
''grossbuchbot.db-queries.datomic.entity-preds/valid-chat?' needs to be listed under :allow in datomic/ion-config.edn

Mark Sto14:07:03

My ion-config.edn looks like this:

{:allow [grossbuchbot.db-queries.datomic.entity-preds/valid-chat?
         grossbuchbot.db-queries.datomic.entity-preds/valid-chat-data?
         grossbuchbot.db-queries.datomic.entity-preds/matching-data-exists?]
 :app-name "<the_same_system_that_is_diverted_locally>"}

Mark Sto14:07:38

So far I’ve managed to check that: • the ion-config.edn file is actually picked up — whenever I move it or rename, I receive the previous error:

Execution error (ExceptionInfo) at datomic.core.require/anomaly! (require.clj:53).
Unable to load namespace for 'grossbuchbot.db-queries.datomic.entity-preds/valid-chat?

favila14:07:15

is your “callsite” possibly double-quoted?

👀 2
Mark Sto14:07:29

• replacing specific symbols in :allow vector with a wildcard doesn’t help — put grossbuchbot.db-queries.datomic.entity-preds/*, received the same error ''grossbuchbot.db-queries.datomic.entity-preds/valid-chat?' needs to be listed under :allow in datomic/ion-config.edn

favila14:07:39

I ask just because of the quote in the error message: for 'grossbuc,,,

Mark Sto14:07:43

Yeah, I reflected whatever was in the https://docs.datomic.com/cloud/schema/schema-reference.html#entity-predicates:

{:db/ident :chat/validate
 :db.entity/attrs [:chat/id :chat/type]
 :db.entity/preds 'grossbuchbot.db-queries.datomic.entity-preds/valid-chat?}
Will try dropping this ' now, one sec.

favila14:07:57

whether that should be quoted or not depends on the outer context of this map

favila14:07:22

if it’s code (e.g. a def in a ns) it should be quoted; if it’s slurped out of an edn file, it shouldn’t be

Mark Sto14:07:34

Yeah, it’s within the EDN file, so it obviously doesn’t require that ' .

Mark Sto14:07:15

Thank you Francis*!* It would be great, if the schema reference could be updated with this minor but crucial detail. Something along the lines of:

Dustin Getz19:11:39

in cloud how is a with-db different than a db, can I just always use with-db ?

favila20:11:04

with-db is a stateful value kept by the remote side

favila20:11:48

in on-prem, that db is just a db object with extra novelty on it; but in cloud it has to be retained by the server and you get a reference to it

favila20:11:03

this also means you need to ensure session-stickiness, and you might lose access to it

favila20:11:06

oddly there’s no explicit resource management so I have no idea how you release it or when it is released.

Dustin Getz21:11:07

oh because in cloud the with-db is remote from the app, so you have to move the speculative txn from app to query server and hopefully only once

favila21:11:37

yes, “with-db” is “make a with-db and give me a pointer to it”

👍 1