Welcome! Please see the About page for a little more info on how this works.

+1 vote
in Cloud by

Hi there,

I wonder if you might be able to help me with something?

I am trying to use an entity spec with datomic to provide constraint checking when entities are transacted/retracted from the database using :db/ensure. This works fine - if my predicate fails the entities are not transacted into Datomic. But in the case where the predicate passes the :db/ensure key/value also appears to be stored in the database - it's visible when I pull the entity out again. This isn't what I expected to happen according to the docs:

https://docs.datomic.com/cloud/schema/schema-reference.html#entity-specs

":db/ensure is a virtual attribute. It is not added in the database; instead it triggers checks based on the named entity."

Have I done something wrong causing :db/ensure to be added to the database? Or have I misunderstood the docs?

I've got a simple test case showing this behaviour if it helps see what I mean. You can find that in the Clojurians Slack channel where I originally asked this question: https://clojurians.slack.com/archives/C03RZMDSH/p1635858493193300

If anyone can point me in the right direction that would be much appreciated, cheers!

1 Answer

0 votes
by

I just described the same question in https://forum.datomic.com/t/db-ensure-doesnt-seem-virtual/2296 with my own example.

Based on the long silence, I'm guessing, it's just a mistake, imprecision or ambiguity in the documentation, that the :db/ensure is described as virtual.

It would be really helpful to clarify this in the docs, because people will just keep wasting time on wondering about it.

...