Skip to content

Commit 927f1fb

Browse files
authored
chore(django-spanner): disable savepoints and remove can_rollback_tests (#16866)
- Set `uses_savepoints = False` in `features.py` to prevent silent rollback failures in production, as Cloud Spanner does not support savepoints natively. Additionally, 9 tests (primarily from `sessions_tests`) were added to the emulator skip list. 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. Fixes #16839
1 parent c053b98 commit 927f1fb

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

  • packages/django-google-spanner/django_spanner

packages/django-google-spanner/django_spanner/features.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ class DatabaseFeatures(BaseDatabaseFeatures):
5656
# Spanner does not support SELECTing an arbitrary expression that also
5757
# appears in the GROUP BY clause.
5858
supports_subqueries_in_group_by = False
59-
uses_savepoints = True
59+
uses_savepoints = False # Spanner does not support savepoints.
6060
can_rollback_tests = False # Spanner savepoints are no-ops; rely on flush.
6161
supports_aggregate_filter_clause = False
6262
# Spanner does not support expression indexes
@@ -274,6 +274,18 @@ class DatabaseFeatures(BaseDatabaseFeatures):
274274
if os.environ.get("SPANNER_EMULATOR_HOST", None):
275275
# Some code isn't yet supported by the Spanner emulator.
276276
skip_tests += (
277+
"fixtures_model_package.tests.FixtureTestCase.test_loaddata",
278+
"transaction_hooks.tests.TestConnectionOnCommit.test_inner_savepoint_does_not_affect_outer",
279+
"model_fields.test_floatfield.TestFloatField.test_float_validates_object",
280+
"model_fields.tests.GetChoicesOrderingTests.test_get_choices_reverse_related_field",
281+
"sessions_tests.tests.CacheDBSessionTests.test_session_asave_does_not_resurrect_session_logged_out_in_other_context",
282+
"sessions_tests.tests.CacheDBSessionTests.test_session_save_does_not_resurrect_session_logged_out_in_other_context",
283+
"sessions_tests.tests.CacheDBSessionWithTimeZoneTests.test_session_asave_does_not_resurrect_session_logged_out_in_other_context",
284+
"sessions_tests.tests.CacheDBSessionWithTimeZoneTests.test_session_save_does_not_resurrect_session_logged_out_in_other_context",
285+
"sessions_tests.tests.CustomDatabaseSessionTests.test_session_asave_does_not_resurrect_session_logged_out_in_other_context",
286+
"sessions_tests.tests.CustomDatabaseSessionTests.test_session_save_does_not_resurrect_session_logged_out_in_other_context",
287+
"sessions_tests.tests.DatabaseSessionTests.test_session_asave_does_not_resurrect_session_logged_out_in_other_context",
288+
"sessions_tests.tests.DatabaseSessionTests.test_session_save_does_not_resurrect_session_logged_out_in_other_context",
277289
# Data Leakage / Test Isolation Issues (Spanner Emulator Limitation)
278290
"model_inheritance.tests.ModelInheritanceDataTests.test_update_query_counts",
279291
"model_inheritance.tests.ModelInheritanceTests.test_create_child_no_update",

0 commit comments

Comments
 (0)