Hi, I’m developing the django backend for CrateDB, as we are a distributed database we do not support auto sequential integer generation, hence some form of random generation is need for unique PKs, we use elasticflakes (somewhate similar to uuid4).
I’d like my users to be able to do something like:
DEFAULT_AUTO_FIELD = "cratedb_django.fields.UUIDField" but non integer auto field are not supported, as seen in #32577 (Add support for `UUIDAutoField` `DEFAULT_AUTO_FIELD`) – Django
I’ve read https://github.com/django/django/pull/18365 and Db default UUID pk by nessita · Pull Request #24 · nessita/django · GitHub but it looks to me that there is still no way of me implementing this, currently I’m doing something like:
CRATE_SQL_AUTO_BIGINT = "bigint default (random() * 2^63-1)::bigint"
CRATE_SQL_AUTO_INTEGER = "integer default (random() * 2^31-1)::integer"
CRATE_SQL_AUTO_SMALLINTEGER = "smallint default (random() * 32767)::smallint"
data_types = {
# todo pgdiff - doc
"AutoField": CRATE_SQL_AUTO_INTEGER,
"BigAutoField": CRATE_SQL_AUTO_BIGINT,
"SmallAutoField": CRATE_SQL_AUTO_SMALLINTEGER,
...
To have ‘randomness’ and integers for the PK, but this is not as robust as I’d like.
Am I missing anything or is it true that non-integer default auto ids are still not a thing, unfortunately?