#18485 closed Cleanup/optimization (fixed)
Document behavior of PostgreSQL/Oracle when manually setting autoincrementing fields
Reported by: | Owned by: | François Freitag | |
---|---|---|---|
Component: | Documentation | Version: | dev |
Severity: | Normal | Keywords: | postgresql oracle autofield |
Cc: | Triage Stage: | Accepted | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
As described in #11423, certain DB backends will not automatically set the sequence number for AutoField-based primary keys if the PKs are explicitly set.
As the ticket discussion states, this is a known feature of PostgreSQL and Oracle, and the 'sqlsequencereset' management command exists to get the sequence in sync. MySQL and SQLite handle the resetting automatically.
Although this difference is inherent at the database level, nothing in Django's database documentation makes this apparent. I would argue that typical Django users would be completely unaware of this issue (as was I, coming from a MySQL background). To me, it looked like a bug in the ORM or in psycopg2.
I suggest that the https://docs.djangoproject.com/en/dev/ref/databases/ page include a warning about this difference, and a reference to the 'sqlsequencereset' command.
Change History (5)
comment:1 by , 12 years ago
Triage Stage: | Unreviewed → Accepted |
---|---|
Type: | Uncategorized → Cleanup/optimization |
comment:2 by , 7 years ago
As noted in ticket:28272#comment:3, Oracle identity columns (which will be created as of Django 2.0; 924a89e135fe54bc7622aa6f03405211e75c06e9) aren't affected.
comment:3 by , 7 years ago
Has patch: | set |
---|---|
Owner: | changed from | to
Status: | new → assigned |
Version: | 1.4 → master |
I think I'd rather put this in the documentation of
AutoField
. Well, the person who writes the patch get to choose :)