Fix: Implement get_sequences() method for Django 4.2+ compatibility
#712
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR implements the missing
get_sequences()method in the tenant schemas database introspection class to fix Django 4.2+ compatibility issues.Problem
Issue #538 reports that running certain Django commands (like
flush) fails with:NotImplementedError: subclasses of BaseDatabaseIntrospection may require a get_sequences() methodThis occurs because Django 4.2+ requires database backends to implement the
get_sequences()method for introspection operations, but the tenant schemas backend was missing this implementation.Solution
This PR provides:
1. Implementation of
get_sequences()method_get_sequences_querySQL that queries PostgreSQL system tablesget_sequences()method that returns sequence information for a given table2. Comprehensive Test Case
introspection.get_sequences()to reproduce the exact error from Django db introspection get_sequences() NotImplementedError on flush #538Testing
Before this fix: Test fails with
NotImplementedErrorAfter this fix: Test passes, confirming the implementation works correctly
Verified with tox test suite across multiple Python/Django combinations.
Credits
This implementation is based on the excellent work by:
Both provided identical, high-quality implementations. This PR consolidates their work with comprehensive testing.
Related
Co-authored-by: barkhabol [email protected]
Co-authored-by: shantanutomarr [email protected]