Document behavior of PostgreSQL/Oracle when manually setting autoincrementing fields
|Reported by:||greg.nicholas@…||Owned by:||nobody|
|Severity:||Normal||Keywords:||postgresql oracle autofield|
|Has patch:||no||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
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.