Opened 11 months ago
Last modified 8 months ago
#35334 assigned Cleanup/optimization
Update Oracle backend supports_sequence_reset = True
Reported by: | David Sanders | Owned by: | Anmol Multani |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | 5.0 |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Accepted | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Pull Requests: | 18024 build:failure | ||
Description ¶
The Oracle backend currently specifies supports_sequence_reset = False
. It looks as though it's been this way since the flag was added to the Oracle backend since https://github.com/django/django/commit/0df4593f0ed.
This commit appears to have been for the 1.5 release [1] which was released in Feb 2013. A few months later Oracle 12.1 [2] was released in July 2013. It's quite hard to determine when ALTER SEQUENCE … RESTART
support was introduced but from some pain-staking searching I found that apparently 12.1 included support for it but it wasn't documented until 18c [3]:
There is a new option for altering a sequence that appeared in 12.1 but was not documented until 18c:
alter SEQUENCE [schema_name.]{sequence_name} restart;
[1] https://docs.djangoproject.com/en/5.0/releases/1.5/
[2] https://en.wikipedia.org/wiki/Oracle_Database#Releases_and_versions
[3] https://www.red-gate.com/simple-talk/databases/oracle-databases/oracle-sequences-12c-features-including-identity/
According to the ticket's flags, the next step(s) to move this issue forward are:
- To provide a patch by sending a pull request. Claim the ticket when you start working so that someone else doesn't duplicate effort. Before sending a pull request, review your work against the patch review checklist. Check the "Has patch" flag on the ticket after sending a pull request and include a link to the pull request in the ticket comment when making that update. The usual format is:
[https://github.com/django/django/pull/#### PR]
.
Change History (3)
comment:1 by , 11 months ago
Triage Stage: | Unreviewed → Accepted |
---|
comment:3 by , 8 months ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
Interestingly someone's already added the required sequence reset methods to
db.backends.oracle.operations.DatabaseOperations
to support flushing: https://github.com/django/django/blob/d658a3162fbeb68d148d1b2fcf4da4fe1437eddb/django/db/backends/oracle/operations.py#L526The Oracle attribute DatabaseOperations.__sequence_reset_sql(), which uses a PL/SQL block, appears to have origins way back to 2007 when it was first added as _get_sequence_reset_sql()
It looks like that could be simplified to use the
ALTER
syntax?