Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion packages/django-google-spanner/django_spanner/features.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class DatabaseFeatures(BaseDatabaseFeatures):
# Spanner does not support SELECTing an arbitrary expression that also
# appears in the GROUP BY clause.
supports_subqueries_in_group_by = False
uses_savepoints = True
uses_savepoints = False # Spanner does not support savepoints.
can_rollback_tests = False # Spanner savepoints are no-ops; rely on flush.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is this value still correct? The comment is at least now outdated, as we explicitly turn off savepoints

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

We can remove this line if we plan to stop supporting versions 5.0/5.1. This is dead code for Django >=5.2.

supports_aggregate_filter_clause = False
# Spanner does not support expression indexes
Expand Down Expand Up @@ -274,6 +274,18 @@ class DatabaseFeatures(BaseDatabaseFeatures):
if os.environ.get("SPANNER_EMULATOR_HOST", None):
# Some code isn't yet supported by the Spanner emulator.
skip_tests += (
"fixtures_model_package.tests.FixtureTestCase.test_loaddata",
"transaction_hooks.tests.TestConnectionOnCommit.test_inner_savepoint_does_not_affect_outer",
"model_fields.test_floatfield.TestFloatField.test_float_validates_object",
"model_fields.tests.GetChoicesOrderingTests.test_get_choices_reverse_related_field",
"sessions_tests.tests.CacheDBSessionTests.test_session_asave_does_not_resurrect_session_logged_out_in_other_context",
"sessions_tests.tests.CacheDBSessionTests.test_session_save_does_not_resurrect_session_logged_out_in_other_context",
"sessions_tests.tests.CacheDBSessionWithTimeZoneTests.test_session_asave_does_not_resurrect_session_logged_out_in_other_context",
"sessions_tests.tests.CacheDBSessionWithTimeZoneTests.test_session_save_does_not_resurrect_session_logged_out_in_other_context",
"sessions_tests.tests.CustomDatabaseSessionTests.test_session_asave_does_not_resurrect_session_logged_out_in_other_context",
"sessions_tests.tests.CustomDatabaseSessionTests.test_session_save_does_not_resurrect_session_logged_out_in_other_context",
"sessions_tests.tests.DatabaseSessionTests.test_session_asave_does_not_resurrect_session_logged_out_in_other_context",
"sessions_tests.tests.DatabaseSessionTests.test_session_save_does_not_resurrect_session_logged_out_in_other_context",
Comment on lines +277 to +288
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

These tests are designed to simulate expected failures within a transaction and rely on savepoints to recover and continue execution. Because we have disabled savepoints (uses_savepoints = False) for production safety, and Cloud Spanner breaks the entire transaction upon encountering any error, these tests are unable to recover and fail with TransactionManagementError. They have been skipped on the emulator as they are fundamentally incompatible with Spanner's transaction model without native savepoint support.

These were passing previously because when uses_savepoints was set to True, our adapter emulated savepoints as dummy no-op statements. This allowed the test flow to proceed without Django immediately detecting that the transaction was broken.

# Data Leakage / Test Isolation Issues (Spanner Emulator Limitation)
"model_inheritance.tests.ModelInheritanceDataTests.test_update_query_counts",
"model_inheritance.tests.ModelInheritanceTests.test_create_child_no_update",
Expand Down
Loading