#23617: The new UUID field does not allow to automatically generate a UUID on
save
-------------------------------------+-------------------------------------
Reporter: thedrow | Owner: zedr
Type: New feature | Status: new
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by mjtamlyn):
The main difference between `AutoField` and a `UUIDField` configured to
act as the primary key is that an `AutoField` is allowed to ask the
database for its value. Because Django does not support database level
defaults in general, this is not possible for a `UUIDField`.
If we are going to fully support alternative fields as `AutoField`-like
fields (see #14286 for example) then we should do it "properly" and allow
database level defaults, using `RETURNING` etc. This is a much more
difficult change involving a lot of work in the migrations framework as
well as the model layer.
I'm not in favour of adding more hackery to `UUIDField` specifically to
deal with this situation - I don't feel it is specific enough to this
particular field.
I'm opening a documentation change to mention that setting `pk = None` is
not necessarily a reliable way of generating a copy when the primary key
is not database generated.
--
Ticket URL: <https://code.djangoproject.com/ticket/23617#comment:10>
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 post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/065.4f07906fa3047d65ff7f4a3ed4bbec42%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.