From 2410992960af991a58d3fb5df220ee80e229db1a Mon Sep 17 00:00:00 2001 From: Tim Graham Date: Fri, 31 Jul 2020 20:45:26 -0400 Subject: [PATCH] enable experimential type conversion https://github.com/cockroachdb/cockroach/issues/49329 --- django_cockroachdb/base.py | 6 ++++++ django_cockroachdb/creation.py | 19 +++++++++++-------- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/django_cockroachdb/base.py b/django_cockroachdb/base.py index 0d8d5338..57d6449e 100644 --- a/django_cockroachdb/base.py +++ b/django_cockroachdb/base.py @@ -62,6 +62,12 @@ def check_constraints(self, table_names=None): # method is a no-op. pass + def init_connection_state(self): + super().init_connection_state() + if self.features.is_cockroachdb_20_2: + with self.connection.cursor() as cursor: + cursor.execute('SET enable_experimental_alter_column_type_general = true') + def chunked_cursor(self): return self.cursor() diff --git a/django_cockroachdb/creation.py b/django_cockroachdb/creation.py index 8eaed248..050bf892 100644 --- a/django_cockroachdb/creation.py +++ b/django_cockroachdb/creation.py @@ -106,25 +106,20 @@ def mark_expected_failures(self): # tablespace SQL because cockroachdb automatically indexes foreign # keys. 'model_options.test_tablespaces.TablespacesTests.test_tablespace_for_many_to_many_field', - # Unsupported type conversion: https://github.com/cockroachdb/cockroach/issues/9851 + # ALTER COLUMN TYPE requiring rewrite of on-disk data is currently + # not supported for columns that are part of an index. + # https://go.crdb.dev/issue/47636 'migrations.test_executor.ExecutorTests.test_alter_id_type_with_fk', 'migrations.test_operations.OperationTests.test_alter_field_pk_fk', 'migrations.test_operations.OperationTests.test_alter_field_reloads_state_on_fk_target_changes', 'migrations.test_operations.OperationTests.test_alter_field_reloads_state_on_fk_with_to_field_related_name_target_type_change', # noqa 'migrations.test_operations.OperationTests.test_alter_field_reloads_state_on_fk_with_to_field_target_changes', # noqa 'migrations.test_operations.OperationTests.test_alter_field_reloads_state_on_fk_with_to_field_target_type_change', # noqa - 'migrations.test_operations.OperationTests.test_alter_fk_non_fk', 'migrations.test_operations.OperationTests.test_rename_field_reloads_state_on_fk_target_changes', 'schema.tests.SchemaTests.test_alter_auto_field_to_char_field', 'schema.tests.SchemaTests.test_alter_autofield_pk_to_smallautofield_pk_sequence_owner', - 'schema.tests.SchemaTests.test_alter_text_field_to_date_field', - 'schema.tests.SchemaTests.test_alter_text_field_to_datetime_field', - 'schema.tests.SchemaTests.test_alter_text_field_to_time_field', - 'schema.tests.SchemaTests.test_alter_textual_field_keep_null_status', 'schema.tests.SchemaTests.test_char_field_pk_to_auto_field', 'schema.tests.SchemaTests.test_char_field_with_db_index_to_fk', - 'schema.tests.SchemaTests.test_m2m_rename_field_in_target_model', - 'schema.tests.SchemaTests.test_rename', 'schema.tests.SchemaTests.test_text_field_with_db_index_to_fk', # cockroachdb doesn't support dropping the primary key. 'schema.tests.SchemaTests.test_alter_int_pk_to_int_unique', @@ -166,6 +161,14 @@ def mark_expected_failures(self): # CharField max_length is ignored. CharField is introspected as # TextField. 'introspection.tests.IntrospectionTests.test_get_table_description_col_lengths', + # Unsupported type conversion: https://github.com/cockroachdb/cockroach/issues/9851 + 'migrations.test_operations.OperationTests.test_alter_fk_non_fk', + 'schema.tests.SchemaTests.test_alter_text_field_to_date_field', + 'schema.tests.SchemaTests.test_alter_text_field_to_datetime_field', + 'schema.tests.SchemaTests.test_alter_text_field_to_time_field', + 'schema.tests.SchemaTests.test_alter_textual_field_keep_null_status', + 'schema.tests.SchemaTests.test_m2m_rename_field_in_target_model', + 'schema.tests.SchemaTests.test_rename', ) for test_name in expected_failures: