#32577: Add support for `UUIDAutoField` `DEFAULT_AUTO_FIELD`
-------------------------------------+-------------------------------------
Reporter: Tomasz Wójcik | Owner: nobody
Type: New feature | Status: new
Component: Database layer | Version: 3.2
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by raydeal):
In my opinion allowing users to use uuid as DEFAULT_AUTO_FIELD isn't good
unless top db providers (Oracle, MS SQL, Postgres, SQLite) will support it
in db as a kind of sequence and they will introduce uuid as auto primary
key type.
DEFAULT_AUTO_FIELD is dedicated to create id field in every model. I can
imagine some situation where UUID is better than INT as Primary Key, but
in most cases it isn't. If it was, the top db providers would implement it
a long time ago.
UUID is random generated value by default and it doesn't guarantee unique
values like a sequence based on INT does. Generation a value is slower
than from sequence.
AutoField in Django that can be DEFAULT_AUTO_FIELD uses db sequence that
gives 100% unique values.
If UUIDAutoField is created in Django based on @Nick Pope proposal
(RandomUUID), it will be worth to add in documentation that **it doesn't
qurantee that value is unique**.
But, definitely, it is worth to allow users to create a custom AutoField
based on any other field type (as reported in #17337), maybe except
Text/Boolean types, and use it as PK. Anyone can then create their own
UUIDAutoField and take responsibility for uniques.
--
Ticket URL: <https://code.djangoproject.com/ticket/32577#comment:16>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/0107017ffb9ac770-9ec1335f-af89-48c5-a639-24d11686aa7e-000000%40eu-central-1.amazonses.com.