Enumerated values in tuples are only eids

When pulling a reference to an enumerated value, the result is an entity map with the db/id and the db/ident:

{:db/ident :some/enumerated-ident
 :db/id    987}

{:db/ident       :some/ref
 :db/valueType   :db.type/ref
 :db/cardinality :db.cardinality/many
 :db/doc         "An example of a reference attribute"}

(d/q '{:find [(pull ?n [:some/ref])]
       :in   [$ ?n]}
     db 999)

=> [{:some/ref [{:db/id 987 :db/ident :some/enumerated-ident}]}]

This is very useful for pulling enumerated values:

However, when pulling a reference to an enumerated value in a tuple attribute, the result is just an eid

{:db/ident :some/enumerated-ident
 :db/id    987}

{:db/ident       :some/tuple
 :db/valueType   :db.type/tuple
 :db/tupleTypes  [:db.type/ref]
 :db/cardinality :db.cardinality/many
 :db/doc         "An example of a tuple attribute with a reference"}

(d/q '{:find [(pull ?n [:some/tuple])]
       :in   [$ ?n]}
     db 999) 

=> [{:some/tuple [987]}]

Which is not so useful for pulling enumerated values. To get the ident, one must unify on the eid in the constraints, ruling out any base entities that might not have a value in :some/tuple (unlike the first example).

3 Likes