Tuple with single item fails transaction

schema

{:db/ident :ns/things,
:db/valueType :db.type/tuple,
:db/tupleType :db.type/string,
:db/cardinality :db.cardinality/one}

Fails when a single value is given. (works when multiple vals in vector i.e [“s” “k”])

(d/transact conn [{:db/id “x” :ns/things [“s”]}])

From docs Homogeneous tuples provide variable length composites ..
How is this variable-length when length can’t be one?

Hi @abhinav,

https://docs.datomic.com/on-prem/schema.html#tuples

A tuple is a collection of 2-8 scalar values, represented in memory as a Clojure vector. There are three kinds of tuples:

I can see why this may be confusing as Homogeneous variable length tuples does not explicitly mention the 2-8 scalar value types, but all tuples are a collection of 2-8 scalar values, including Homogeneous tuples. I will correct the docs to explicitly say that. You must have multiple items in the vector 2 or greater.

Additionally you may be interested in knowing that, nil is a legal value for any slot in a tuple. This facilitates using tuples in range searches, where nil sorts lowest.

1 Like