#35957: Allow AutoFields in composite primary keys
-------------------------------------+-------------------------------------
Reporter: Csirmaz Bendegúz | Type: New
| feature
Status: new | Component: Database
| layer (models, ORM)
Version: dev | Severity: Normal
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
This is a follow up to #373 (''CompositePrimaryKey''), #8576 (''Multiple
AutoFields in a model''), #27452 (''SerialField'').
At the moment, `AutoField`s must set `primary_key=True`.
This makes it impossible to use them with `CompositePrimaryKey`.
''Multiple AutoFields in a model'' (#8576) may not be useful, but having
an `AutoField` be part of a composite primary key has its uses. It's good
practice to use surrogate keys, even if the table has a composite primary
key (should this surrogate key be an auto-incremented field is another
discussion).
So I think we should allow `AutoField`s to not set `primary_key=True` if
they are part of a composite primary key.
Note: SQLite doesn't support AutoFields in composite primary keys.
--
Ticket URL: <https://code.djangoproject.com/ticket/35957>
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 visit
https://groups.google.com/d/msgid/django-updates/010701937a8f4faa-4e41cfcd-7022-4668-bcc3-6996fbc63dbe-000000%40eu-central-1.amazonses.com.