datomic.db.DbId tempids vs String tempids as arguments to queries

We sometimes send tempids (as strings or datomic.api/tempid) around for new items where a ref or eid would be used if the entity is already avail in the db.

As it happened we sent a tempid in the form of a string to a query, which gave us an exception like:

Execution error (Exceptions$IllegalArgumentExceptionInfo) at datomic.error/arg (error.clj:79).
:db.error/not-a-keyword Cannot interpret as a keyword: example-string, no leading :

which is formally correct since Datomic accepts :db/ident keywords in the form of strings, under the condition that the string starts with a :. This is to make the Java API more usable, which is a reasonable trade-off.

When using an ordinary tempid created with (datomic.api/tempid :db.part/user) as a query argument, the query did return an empty result, which is generally correct (as long as you know that the tempid could be resolved to an existing entity in the transaction using some other data in the transaction, like a lookup ref or index attribute).

In this particular use case, especially using Clojure, not Java, as the host language, it would have been less surprising if strings not starting with : was treated as tempids when they where resolved in querys etc and returned some non-result.