From 6938f776d7fa010ac7488a20e93920980f32d275 Mon Sep 17 00:00:00 2001 From: Vikash Singh <3116482+vi3k6i5@users.noreply.github.com> Date: Tue, 3 Aug 2021 18:48:59 +0530 Subject: [PATCH 1/8] docs: lint fix for samples --- docs/samples.rst | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/docs/samples.rst b/docs/samples.rst index 4d9ef417a2..3e20575e24 100644 --- a/docs/samples.rst +++ b/docs/samples.rst @@ -13,12 +13,12 @@ the following two models: from django.db import models class Question(models.Model): - question_text = models.CharField(max_length=200) - pub_date = models.DateTimeField('date published') - def __str__(self): - return str(self.rating) + question_text = models.CharField(max_length=200) + pub_date = models.DateTimeField('date published') + def __str__(self): + return str(self.rating) class Choice(models.Model): - question = models.ForeignKey(Question, on_delete=models.CASCADE) - choice_text = models.CharField(max_length=200) - votes = models.IntegerField(default=0) + question = models.ForeignKey(Question, on_delete=models.CASCADE) + choice_text = models.CharField(max_length=200) + votes = models.IntegerField(default=0) From b500f29b0b77d75bb99ad3699ce134125c997982 Mon Sep 17 00:00:00 2001 From: Vikash Singh <3116482+vi3k6i5@users.noreply.github.com> Date: Mon, 11 Oct 2021 20:49:51 +0530 Subject: [PATCH 2/8] feat: enable foreign key support --- README.rst | 5 +- django_spanner/features.py | 134 +++++++++++++++++++++++++++++--- django_spanner/introspection.py | 36 +++++++-- django_spanner/schema.py | 14 +++- 4 files changed, 168 insertions(+), 21 deletions(-) diff --git a/README.rst b/README.rst index 62739a3182..b150aa1294 100644 --- a/README.rst +++ b/README.rst @@ -364,7 +364,4 @@ Additions cannot include ``None`` values. For example: :: - >>> Book.objects.annotate(adjusted_rating=F('rating') + None) - ... - google.api_core.exceptions.InvalidArgument: 400 Operands of + cannot be literal - NULL ... +Django spanner has a set of limitations as well, please go through the `list `_. diff --git a/django_spanner/features.py b/django_spanner/features.py index a0ae6299c3..16e92aaf8b 100644 --- a/django_spanner/features.py +++ b/django_spanner/features.py @@ -13,7 +13,7 @@ class DatabaseFeatures(BaseDatabaseFeatures): can_introspect_big_integer_field = False can_introspect_duration_field = False - can_introspect_foreign_keys = False + can_introspect_foreign_keys = True # TimeField is introspected as DateTimeField because they both use # TIMESTAMP. can_introspect_time_field = False @@ -22,7 +22,12 @@ class DatabaseFeatures(BaseDatabaseFeatures): has_case_insensitive_like = False # https://cloud.google.com/spanner/quotas#query_limits max_query_params = 900 +<<<<<<< Updated upstream supports_foreign_keys = False +======= + supports_foreign_keys = True + can_create_inline_fk = False +>>>>>>> Stashed changes supports_ignore_conflicts = False supports_partial_indexes = False supports_regex_backreferencing = False @@ -36,11 +41,13 @@ class DatabaseFeatures(BaseDatabaseFeatures): # Django tests that aren't supported by Spanner. skip_tests = ( - # No foreign key constraints in Spanner. + # Spanner does not support very long FK name: 400 Foreign Key name not valid "backends.tests.FkConstraintsTests.test_check_constraints", + "backends.tests.FkConstraintsTests.test_check_constraints_sql_keywords", + # No foreign key ON DELETE CASCADE in Spanner. + "fixtures_regress.tests.TestFixtures.test_loaddata_raises_error_when_fixture_has_invalid_foreign_key", # Spanner does not support empty list of DML statement. "backends.tests.BackendTestCase.test_cursor_executemany_with_empty_params_list", - "fixtures_regress.tests.TestFixtures.test_loaddata_raises_error_when_fixture_has_invalid_foreign_key", # No Django transaction management in Spanner. "basic.tests.SelectOnSaveTests.test_select_on_save_lying_update", # django_spanner monkey patches AutoField to have a default value. @@ -274,12 +281,6 @@ class DatabaseFeatures(BaseDatabaseFeatures): "introspection.tests.IntrospectionTests.test_table_names_with_views", # No sequence for AutoField in Spanner. "introspection.tests.IntrospectionTests.test_sequence_list", - # DatabaseIntrospection.get_key_columns() is only required if this - # backend needs it (which it currently doesn't). - "introspection.tests.IntrospectionTests.test_get_key_columns", - # DatabaseIntrospection.get_relations() isn't implemented: - # https://github.com/googleapis/python-spanner-django/issues/311 - "introspection.tests.IntrospectionTests.test_get_relations", # pyformat parameters not supported on INSERT: # https://github.com/googleapis/python-spanner-django/issues/343 "backends.tests.BackendTestCase.test_cursor_execute_with_pyformat", @@ -375,6 +376,121 @@ class DatabaseFeatures(BaseDatabaseFeatures): "view_tests.tests.test_csrf.CsrfViewTests.test_no_referer", "view_tests.tests.test_i18n.SetLanguageTests.test_lang_from_translated_i18n_pattern", ) + if USING_DJANGO_3: + skip_tests += ( + # Spanner does not support UUID field natively + "model_fields.test_uuid.TestQuerying.test_iexact", + # Spanner does not support setting a default value on columns. + "schema.tests.SchemaTests.test_alter_text_field_to_not_null_with_default_value", + # Direct SQL query test that do not follow spanner syntax. + "schema.tests.SchemaTests.test_alter_auto_field_quoted_db_column", + "schema.tests.SchemaTests.test_alter_primary_key_quoted_db_table", + # Insert sql with param variables using %(name)s parameter style is failing + # https://github.com/googleapis/python-spanner/issues/542 + "backends.tests.LastExecutedQueryTest.test_last_executed_query_dict", + # Spanner autofield is replaced with uuid4 so validation is disabled + "model_fields.test_autofield.AutoFieldTests.test_backend_range_validation", + "model_fields.test_autofield.AutoFieldTests.test_redundant_backend_range_validators", + "model_fields.test_autofield.AutoFieldTests.test_redundant_backend_range_validators", + "model_fields.test_autofield.BigAutoFieldTests.test_backend_range_validation", + "model_fields.test_autofield.BigAutoFieldTests.test_redundant_backend_range_validators", + "model_fields.test_autofield.BigAutoFieldTests.test_redundant_backend_range_validators", + "model_fields.test_autofield.SmallAutoFieldTests.test_backend_range_validation", + "model_fields.test_autofield.SmallAutoFieldTests.test_redundant_backend_range_validators", + "model_fields.test_autofield.SmallAutoFieldTests.test_redundant_backend_range_validators", + # Spanner does not support deferred unique constraints + "migrations.test_operations.OperationTests.test_create_model_with_deferred_unique_constraint", + # Spanner does not support JSON object query on fields. + "db_functions.comparison.test_json_object.JSONObjectTests.test_empty", + "db_functions.comparison.test_json_object.JSONObjectTests.test_basic", + "db_functions.comparison.test_json_object.JSONObjectTests.test_expressions", + "db_functions.comparison.test_json_object.JSONObjectTests.test_nested_empty_json_object", + "db_functions.comparison.test_json_object.JSONObjectTests.test_nested_json_object", + "db_functions.comparison.test_json_object.JSONObjectTests.test_textfield", + # Spanner does not support iso_week_day but week_day is supported. + "timezones.tests.LegacyDatabaseTests.test_query_datetime_lookups", + "timezones.tests.NewDatabaseTests.test_query_datetime_lookups", + "timezones.tests.NewDatabaseTests.test_query_datetime_lookups_in_other_timezone", + "db_functions.datetime.test_extract_trunc.DateFunctionTests.test_extract_func", + "db_functions.datetime.test_extract_trunc.DateFunctionTests.test_extract_iso_weekday_func", + "db_functions.datetime.test_extract_trunc.DateFunctionWithTimeZoneTests.test_extract_func", + "db_functions.datetime.test_extract_trunc.DateFunctionWithTimeZoneTests.test_extract_func_with_timezone", + "db_functions.datetime.test_extract_trunc.DateFunctionWithTimeZoneTests.test_extract_func_with_timezone", + "db_functions.datetime.test_extract_trunc.DateFunctionWithTimeZoneTests.test_extract_iso_weekday_func", + # Spanner gived SHA encryption output in bytes, django expects it in hex string format. + "db_functions.text.test_sha512.SHA512Tests.test_basic", + "db_functions.text.test_sha512.SHA512Tests.test_transform", + "db_functions.text.test_md5.MD5Tests.test_basic", + "db_functions.text.test_md5.MD5Tests.test_transform", + "db_functions.text.test_sha1.SHA1Tests.test_basic", + "db_functions.text.test_sha1.SHA1Tests.test_transform", + "db_functions.text.test_sha224.SHA224Tests.test_basic", + "db_functions.text.test_sha224.SHA224Tests.test_transform", + "db_functions.text.test_sha256.SHA256Tests.test_basic", + "db_functions.text.test_sha256.SHA256Tests.test_transform", + "db_functions.text.test_sha384.SHA384Tests.test_basic", + "db_functions.text.test_sha384.SHA384Tests.test_transform", + # Spanner does not support RANDOM number generation function + "db_functions.math.test_random.RandomTests.test", + # Spanner supports order by id, but it's does not work the same way as + # an auto increment field. + "model_forms.test_modelchoicefield.ModelChoiceFieldTests.test_choice_iterator_passes_model_to_widget", + "queries.test_qs_combinators.QuerySetSetOperationTests.test_union_with_values_list_and_order", + "ordering.tests.OrderingTests.test_order_by_self_referential_fk", + "fixtures.tests.ForwardReferenceTests.test_forward_reference_m2m_natural_key", + "fixtures.tests.ForwardReferenceTests.test_forward_reference_fk_natural_key", + # Spanner does not support empty list of DML statement. + "backends.tests.BackendTestCase.test_cursor_executemany_with_empty_params_list", + # Spanner does not support SELECTing an arbitrary expression that also + # appears in the GROUP BY clause. + "annotations.tests.NonAggregateAnnotationTestCase.test_grouping_by_q_expression_annotation", + # No Django transaction management in Spanner. + "transactions.tests.DisableDurabiltityCheckTests.test_nested_both_durable", + "transactions.tests.DisableDurabiltityCheckTests.test_nested_inner_durable", + # Tests that expect it to be empty untill saved in db. + "test_utils.test_testcase.TestDataTests.test_class_attribute_identity", + "model_fields.test_jsonfield.TestSerialization.test_dumping", + "model_fields.test_jsonfield.TestSerialization.test_dumping", + "model_fields.test_jsonfield.TestSerialization.test_dumping", + "model_fields.test_jsonfield.TestSerialization.test_xml_serialization", + "model_fields.test_jsonfield.TestSerialization.test_xml_serialization", + "model_fields.test_jsonfield.TestSerialization.test_xml_serialization", + "bulk_create.tests.BulkCreateTests.test_unsaved_parent", + # Tests that assume a serial pk. + "lookup.tests.LookupTests.test_exact_query_rhs_with_selected_columns", + "prefetch_related.tests.DirectPrefetchedObjectCacheReuseTests.test_detect_is_fetched", + "prefetch_related.tests.DirectPrefetchedObjectCacheReuseTests.test_detect_is_fetched_with_to_attr", + # datetimes retrieved from the database with the wrong hour when + # USE_TZ = True: https://github.com/googleapis/python-spanner-django/issues/193 + "timezones.tests.NewDatabaseTests.test_query_convert_timezones", + # Spanner doesn't support random ordering. + "aggregation.tests.AggregateTestCase.test_aggregation_random_ordering", + # Tests that require transactions. + "test_utils.tests.CaptureOnCommitCallbacksTests.test_execute", + "test_utils.tests.CaptureOnCommitCallbacksTests.test_no_arguments", + "test_utils.tests.CaptureOnCommitCallbacksTests.test_pre_callback", + "test_utils.tests.CaptureOnCommitCallbacksTests.test_using", + # Field: GenericIPAddressField is mapped to String in Spanner + "inspectdb.tests.InspectDBTestCase.test_field_types", + # BigIntegerField is mapped to IntegerField in Spanner + "inspectdb.tests.InspectDBTestCase.test_number_field_types", + # Spanner limitation: Cannot change type of column. + "schema.tests.SchemaTests.test_char_field_pk_to_auto_field", + "schema.tests.SchemaTests.test_ci_cs_db_collation", + # Spanner limitation: Cannot rename tables and columns. + "migrations.test_operations.OperationTests.test_rename_field_case", + # Tests that sometimes fail on Kokoro for unknown reasons. + "migrations.test_operations.OperationTests.test_add_constraint_combinable", + # Tests that fail but are not related to spanner. + "test_utils.test_testcase.TestDataTests.test_undeepcopyable_warning", + ) + else: + # Tests specific to django 2.2 + skip_tests += ( + # Tests that assume a serial pk. + "prefetch_related.tests.DirectPrefechedObjectCacheReuseTests.test_detect_is_fetched", + "prefetch_related.tests.DirectPrefechedObjectCacheReuseTests.test_detect_is_fetched_with_to_attr", + ) if os.environ.get("SPANNER_EMULATOR_HOST", None): # Some code isn't yet supported by the Spanner emulator. diff --git a/django_spanner/introspection.py b/django_spanner/introspection.py index b95ea3e629..2cf803e99e 100644 --- a/django_spanner/introspection.py +++ b/django_spanner/introspection.py @@ -105,11 +105,6 @@ def get_relations(self, cursor, table_name): """Return a dictionary of {field_name: (field_name_other_table, other_table)} representing all the relationships in the table. - TODO: DO NOT USE THIS METHOD UNTIL - https://github.com/googleapis/python-spanner-django/issues/313 - is resolved so that foreign keys can be supported, as documented in: - https://github.com/googleapis/python-spanner-django/issues/311 - :type cursor: :class:`~google.cloud.spanner_dbapi.cursor.Cursor` :param cursor: A reference to a Spanner Database cursor. @@ -303,3 +298,34 @@ def get_constraints(self, cursor, table_name): constraints[index_name]["unique"] = is_unique return constraints + + def get_key_columns(self, cursor, table_name): + """ + Return a list of (column_name, referenced_table, referenced_column) + for all key columns in the given table. + """ + key_columns = [] + cursor.execute( + """ + SELECT + tc.COLUMN_NAME as column_name, + ccu.TABLE_NAME as referenced_table, + ccu.COLUMN_NAME as referenced_column + from + INFORMATION_SCHEMA.KEY_COLUMN_USAGE AS tc + JOIN + INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS as rc + ON + tc.CONSTRAINT_NAME = rc.CONSTRAINT_NAME + JOIN + INFORMATION_SCHEMA.CONSTRAINT_COLUMN_USAGE as ccu + ON + rc.CONSTRAINT_NAME = ccu.CONSTRAINT_NAME + WHERE + tc.TABLE_NAME="{table}" + """.format( + table=self.connection.ops.quote_name(table_name) + ) + ) + key_columns.extend(cursor.fetchall()) + return key_columns diff --git a/django_spanner/schema.py b/django_spanner/schema.py index 247358857a..d3926e7dea 100644 --- a/django_spanner/schema.py +++ b/django_spanner/schema.py @@ -40,6 +40,7 @@ class DatabaseSchemaEditor(BaseDatabaseSchemaEditor): sql_alter_column_type = "ALTER COLUMN %(column)s %(type)s" sql_delete_column = "ALTER TABLE %(table)s DROP COLUMN %(column)s" + sql_create_inline_fk = "CONSTRAINT FK_%(to_table)s_%(to_column)s_%(from_table)s_%(from_column)s FOREIGN KEY (%(from_column_norm)s) REFERENCES %(to_table_norm)s (%(to_column_norm)s)" def create_model(self, model): """ @@ -68,14 +69,21 @@ def create_model(self, model): params.extend(extra_params) # FK if field.remote_field and field.db_constraint: + from_table = field.model._meta.db_table + from_column = field.column to_table = field.remote_field.model._meta.db_table to_column = field.remote_field.model._meta.get_field( field.remote_field.field_name ).column if self.sql_create_inline_fk: - definition += " " + self.sql_create_inline_fk % { - "to_table": self.quote_name(to_table), - "to_column": self.quote_name(to_column), + definition += ", " + self.sql_create_inline_fk % { + "from_table": from_table, + "from_column": from_column, + "to_table": to_table, + "to_column": to_column, + "from_column_norm": self.quote_name(from_column), + "to_table_norm": self.quote_name(to_table), + "to_column_norm": self.quote_name(to_column), } elif self.connection.features.supports_foreign_keys: self.deferred_sql.append( From 91f2358659396ecbcb235c374e5b10988ba92116 Mon Sep 17 00:00:00 2001 From: Vikash Singh <3116482+vi3k6i5@users.noreply.github.com> Date: Mon, 11 Oct 2021 21:04:12 +0530 Subject: [PATCH 3/8] feat: add support for spanner fk --- README.rst | 2 +- django_spanner/features.py | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/README.rst b/README.rst index 4f0d9ca886..93f7116271 100644 --- a/README.rst +++ b/README.rst @@ -260,4 +260,4 @@ LIMITATIONS Spanner has certain limitations of it's own and a full set of limitations are documented over `here `_ It is recommended that you go through that list. -Django spanner has a set of limitations as well, please go through the `list `_. +Django spanner has a set of limitations as well, please go through the `list `_. diff --git a/django_spanner/features.py b/django_spanner/features.py index 5757640208..ff280265bc 100644 --- a/django_spanner/features.py +++ b/django_spanner/features.py @@ -23,7 +23,7 @@ class DatabaseFeatures(BaseDatabaseFeatures): has_case_insensitive_like = False # https://cloud.google.com/spanner/quotas#query_limits max_query_params = 900 - supports_foreign_keys = False + supports_foreign_keys = True can_create_inline_fk = False supports_ignore_conflicts = False supports_partial_indexes = False @@ -448,8 +448,6 @@ class DatabaseFeatures(BaseDatabaseFeatures): # Spanner does not support SELECTing an arbitrary expression that also # appears in the GROUP BY clause. "annotations.tests.NonAggregateAnnotationTestCase.test_grouping_by_q_expression_annotation", - # No foreign key constraints in Spanner. - "backends.tests.FkConstraintsTests.test_check_constraints_sql_keywords", # No Django transaction management in Spanner. "transactions.tests.DisableDurabiltityCheckTests.test_nested_both_durable", "transactions.tests.DisableDurabiltityCheckTests.test_nested_inner_durable", From 7c1ad0f416737f65cce2b59da18e6182ee854b84 Mon Sep 17 00:00:00 2001 From: Vikash Singh <3116482+vi3k6i5@users.noreply.github.com> Date: Mon, 11 Oct 2021 21:41:54 +0530 Subject: [PATCH 4/8] feat: disable foreign key as without on delete cascade the db cleanup process fails --- django_spanner/features.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/django_spanner/features.py b/django_spanner/features.py index ff280265bc..b292c3d5ff 100644 --- a/django_spanner/features.py +++ b/django_spanner/features.py @@ -14,7 +14,7 @@ class DatabaseFeatures(BaseDatabaseFeatures): can_introspect_big_integer_field = False can_introspect_duration_field = False - can_introspect_foreign_keys = True + can_introspect_foreign_keys = False # TimeField is introspected as DateTimeField because they both use # TIMESTAMP. can_introspect_time_field = False @@ -23,7 +23,7 @@ class DatabaseFeatures(BaseDatabaseFeatures): has_case_insensitive_like = False # https://cloud.google.com/spanner/quotas#query_limits max_query_params = 900 - supports_foreign_keys = True + supports_foreign_keys = False can_create_inline_fk = False supports_ignore_conflicts = False supports_partial_indexes = False From 11748f080da6d08931f860351ffec410a7c997fb Mon Sep 17 00:00:00 2001 From: Vikash Singh <3116482+vi3k6i5@users.noreply.github.com> Date: Tue, 12 Oct 2021 00:49:03 +0530 Subject: [PATCH 5/8] fix: add comment as to why foreign key creation is disabled in django --- django_spanner/introspection.py | 3 +-- django_spanner/schema.py | 5 ++++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/django_spanner/introspection.py b/django_spanner/introspection.py index 5183f58242..4861751acf 100644 --- a/django_spanner/introspection.py +++ b/django_spanner/introspection.py @@ -351,8 +351,7 @@ def get_key_columns(self, cursor, table_name): """ key_columns = [] cursor.execute( - """ - SELECT + """SELECT tc.COLUMN_NAME as column_name, ccu.TABLE_NAME as referenced_table, ccu.COLUMN_NAME as referenced_column diff --git a/django_spanner/schema.py b/django_spanner/schema.py index f96b6d5998..2ef4ea7d24 100644 --- a/django_spanner/schema.py +++ b/django_spanner/schema.py @@ -41,7 +41,10 @@ class DatabaseSchemaEditor(BaseDatabaseSchemaEditor): sql_alter_column_type = "ALTER COLUMN %(column)s %(type)s" sql_delete_column = "ALTER TABLE %(table)s DROP COLUMN %(column)s" - sql_create_inline_fk = "CONSTRAINT FK_%(to_table)s_%(to_column)s_%(from_table)s_%(from_column)s FOREIGN KEY (%(from_column_norm)s) REFERENCES %(to_table_norm)s (%(to_column_norm)s)" + # Spanner does not suppport ON DELETE CASCADE for foreign keys. + # This can cause failures in django, hence sql_create_inline_fk is disabled. + # sql_create_inline_fk = "CONSTRAINT FK_%(to_table)s_%(to_column)s_%(from_table)s_%(from_column)s FOREIGN KEY (%(from_column_norm)s) REFERENCES %(to_table_norm)s (%(to_column_norm)s)" # noqa + sql_create_inline_fk = None def create_model(self, model): """ From 51b3438457d2978e55c8c98ca9d9cb9622fd3dc9 Mon Sep 17 00:00:00 2001 From: Vikash Singh <3116482+vi3k6i5@users.noreply.github.com> Date: Tue, 12 Oct 2021 10:51:26 +0530 Subject: [PATCH 6/8] fix: move test_check_constraints_sql_keywords to django3.2 skipped tests --- django_spanner/features.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/django_spanner/features.py b/django_spanner/features.py index b292c3d5ff..0c2da8fadd 100644 --- a/django_spanner/features.py +++ b/django_spanner/features.py @@ -63,7 +63,6 @@ class DatabaseFeatures(BaseDatabaseFeatures): skip_tests = ( # Spanner does not support very long FK name: 400 Foreign Key name not valid "backends.tests.FkConstraintsTests.test_check_constraints", - "backends.tests.FkConstraintsTests.test_check_constraints_sql_keywords", # No foreign key ON DELETE CASCADE in Spanner. "fixtures_regress.tests.TestFixtures.test_loaddata_raises_error_when_fixture_has_invalid_foreign_key", # Spanner does not support empty list of DML statement. @@ -384,6 +383,8 @@ class DatabaseFeatures(BaseDatabaseFeatures): skip_tests += ( # Spanner does not support UUID field natively "model_fields.test_uuid.TestQuerying.test_iexact", + # Spanner does not support very long FK name: 400 Foreign Key name not valid + "backends.tests.FkConstraintsTests.test_check_constraints_sql_keywords", # Spanner does not support setting a default value on columns. "schema.tests.SchemaTests.test_alter_text_field_to_not_null_with_default_value", # Direct SQL query test that do not follow spanner syntax. From 3879a557541714d5adfdf1a816f4b469cd932e13 Mon Sep 17 00:00:00 2001 From: Vikash Singh <3116482+vi3k6i5@users.noreply.github.com> Date: Tue, 12 Oct 2021 13:00:19 +0530 Subject: [PATCH 7/8] chor: cleanup tests --- django_spanner/features.py | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/django_spanner/features.py b/django_spanner/features.py index 0c2da8fadd..0bf8cc6e02 100644 --- a/django_spanner/features.py +++ b/django_spanner/features.py @@ -120,6 +120,7 @@ class DatabaseFeatures(BaseDatabaseFeatures): "validation.test_validators.TestModelsWithValidators.test_custom_validator_raises_error_for_incorrect_value", "validation.test_validators.TestModelsWithValidators.test_field_validators_can_be_any_iterable", # Tests that assume a serial pk. + "servers.tests.LiveServerDatabase.test_fixtures_loaded", "admin_filters.tests.ListFiltersTests.test_booleanfieldlistfilter_nullbooleanfield", "admin_filters.tests.ListFiltersTests.test_booleanfieldlistfilter_tuple", "admin_filters.tests.ListFiltersTests.test_booleanfieldlistfilter", @@ -370,14 +371,6 @@ class DatabaseFeatures(BaseDatabaseFeatures): "model_forms.tests.UniqueTest.test_override_unique_together_message", # os.chmod() doesn't work on Kokoro? "file_uploads.tests.DirectoryCreationTests.test_readonly_root", - # Tests that sometimes fail on Kokoro for unknown reasons. - "contenttypes_tests.test_models.ContentTypesTests.test_cache_not_shared_between_managers", - "migration_test_data_persistence.tests.MigrationDataNormalPersistenceTestCase.test_persistence", - "servers.test_liveserverthread.LiveServerThreadTest.test_closes_connections", - "servers.tests.LiveServerDatabase.test_fixtures_loaded", - "view_tests.tests.test_csrf.CsrfViewTests.test_no_cookies", - "view_tests.tests.test_csrf.CsrfViewTests.test_no_referer", - "view_tests.tests.test_i18n.SetLanguageTests.test_lang_from_translated_i18n_pattern", ) if USING_DJANGO_3: skip_tests += ( @@ -484,9 +477,7 @@ class DatabaseFeatures(BaseDatabaseFeatures): "schema.tests.SchemaTests.test_ci_cs_db_collation", # Spanner limitation: Cannot rename tables and columns. "migrations.test_operations.OperationTests.test_rename_field_case", - # Tests that sometimes fail on Kokoro for unknown reasons. - "migrations.test_operations.OperationTests.test_add_constraint_combinable", - # Tests that fail but are not related to spanner. + # Warning is not raised, not related to spanner. "test_utils.test_testcase.TestDataTests.test_undeepcopyable_warning", ) else: From 62cb092f50e685cd787dd9e8b48c9d6890bab6e0 Mon Sep 17 00:00:00 2001 From: Vikash Singh <3116482+vi3k6i5@users.noreply.github.com> Date: Tue, 12 Oct 2021 14:10:58 +0530 Subject: [PATCH 8/8] tests: add failing tests in skipped test --- django_spanner/features.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/django_spanner/features.py b/django_spanner/features.py index 0bf8cc6e02..d2099a78f0 100644 --- a/django_spanner/features.py +++ b/django_spanner/features.py @@ -371,6 +371,8 @@ class DatabaseFeatures(BaseDatabaseFeatures): "model_forms.tests.UniqueTest.test_override_unique_together_message", # os.chmod() doesn't work on Kokoro? "file_uploads.tests.DirectoryCreationTests.test_readonly_root", + # Failing on kokoro but passes locally. Issue: Multiple queries executed expected 1. + "contenttypes_tests.test_models.ContentTypesTests.test_cache_not_shared_between_managers", ) if USING_DJANGO_3: skip_tests += (