Skip to content

Conversation

NandanaRaol
Copy link
Contributor

@NandanaRaol NandanaRaol commented Jun 3, 2025

This pull request introduces support for testing Django 5.1 across multiple Python versions in the CI pipeline and resolves potential circular import issues in the test suite by adjusting import order and references to database operations. Below are the key changes:

Test Suite Improvements:

  • Updated test_multiple_databases.py to import BaseDatabaseOperations before sqlite3.operations.DatabaseOperations, preventing potential circular import issues and ensuring the base class is available for subclassing.
  • Modified test_in_split_parameter_list_as_sql to reference BaseDatabaseOperations.max_in_list_size instead of DatabaseOperations.max_in_list_size, aligning with the updated import order and improving clarity.

Prefer Modifying BaseDatabaseOperations Over connections[].ops for Cleaner and Backend-Agnostic Test Behavior

  • Instead of accessing the database operations through connections['default'].ops and modifying
    the instance-level method, I switched to modifying the class method on BaseDatabaseOperations.
    Though both approaches technically work, directly using BaseDatabaseOperations is more efficient and maintainable:
  • It ensures consistency across all operations using the base class, not just a single connection instance.
  • It is cleaner and backend-agnostic, especially useful in test cases where we want to simulate global behavior like max parameter limits.
    This approach also aligns better with Django's extensibility model, where backend-specific behavior typically extends BaseDatabaseOperations.

Doc Link: Circular Import-support 5.1.loop
ADO Link: https://sqlclientdrivers.visualstudio.com/mssql-django/_workitems/edit/37633

@Copilot Copilot AI review requested due to automatic review settings June 3, 2025 18:39
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Adds Django 5.1 compatibility in CI and resolves circular import issues in the test suite by adjusting import order.

  • Adjust import and references in test_multiple_databases.py to use BaseDatabaseOperations first.
  • Extend the Azure Pipelines matrix to run tests on Python 3.10–3.13 with Django 5.1.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
testapp/tests/test_multiple_databases.py Import BaseDatabaseOperations first and update references
azure-pipelines.yml Add Python 3.10–3.13 – Django 5.1 entries to the CI matrix

@NandanaRaol NandanaRaol changed the title TASK2: Resolved Circular Import Issue In Testapp FIX: Support 5.1-Resolved Circular Import Issue In Testapp Jun 3, 2025
@NandanaRaol NandanaRaol force-pushed the Nandana/5.1/circularimport branch from cbb3714 to b29f0d4 Compare June 5, 2025 06:56
Copy link
Collaborator

@bewithgaurav bewithgaurav left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved. Since this is specific to the circular import issue, the django tests in 5.1 will be failing right now, which will be getting fixed the subsequent PRs as we tackle more of 5.1 support issues. Please add the below:

  • ADO & Doc Links in the description
  • Add a comment explaining the approaches we followed prior to this and why we chose this approach

@NandanaRaol NandanaRaol merged commit 30e7496 into dev Jun 5, 2025
41 of 50 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants