From 8f6519245fd0851c045af67d880e0edd21167a25 Mon Sep 17 00:00:00 2001 From: Tim Graham Date: Thu, 18 Sep 2025 09:30:55 -0400 Subject: [PATCH 1/2] drop support for CockroachDB 24.1 --- .github/workflows/tests.yml | 5 ----- django_cockroachdb/features.py | 35 ++++++---------------------------- 2 files changed, 6 insertions(+), 34 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 0431691..f1d9690 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -29,11 +29,6 @@ jobs: fail-fast: false matrix: include: - - crdb-version: v24.1.14 - - crdb-version: v24.1.14 - use_psycopg2: psycopg2 - - crdb-version: v24.1.14 - use_server_side_binding: server_side_binding - crdb-version: v24.3.8 - crdb-version: v24.3.8 use_psycopg2: psycopg2 diff --git a/django_cockroachdb/features.py b/django_cockroachdb/features.py index b09bfc1..00a6c15 100644 --- a/django_cockroachdb/features.py +++ b/django_cockroachdb/features.py @@ -75,10 +75,6 @@ def introspected_field_types(self): 'virtual': None, } - @cached_property - def is_cockroachdb_24_3(self): - return self.connection.cockroachdb_version >= (24, 3) - @cached_property def is_cockroachdb_25_1(self): return self.connection.cockroachdb_version >= (25, 1) @@ -195,22 +191,6 @@ def django_test_expected_failures(self): # ProgrammingError: VALUES types int and float cannot be matched 'field_defaults.tests.DefaultTests.test_bulk_create_mixed_db_defaults_function', }) - if not self.is_cockroachdb_24_3: - expected_failures.update({ - # 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 - 'schema.tests.SchemaTests.test_alter_primary_key_the_same_name', - '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_target_changes', # noqa - 'migrations.test_operations.OperationTests.test_rename_field_reloads_state_on_fk_target_changes', - # unknown signature: concat(varchar, int) (returning ) - 'migrations.test_operations.OperationTests.test_add_generated_field', - # concat(): unknown signature: concat(string, int2) (desired ) - 'db_functions.text.test_concat.ConcatTests.test_concat_non_str', - # unknown signature: concat(timestamptz, string) - "aggregation.tests.AggregateTestCase.test_string_agg_order_by", - }) if self.is_cockroachdb_25_1: expected_failures.update({ # expected STORED COMPUTED COLUMN expression to have type @@ -259,6 +239,12 @@ def django_test_expected_failures(self): 'queries.test_bulk_update.BulkUpdateTests.test_updated_rows_when_passing_duplicates', 'queries.test_q.QCheckTests.test_expression', 'queries.test_qs_combinators.QuerySetSetOperationTests.test_union_multiple_models_with_values_list_and_annotations', # noqa + # psycopg.errors.IndeterminateDatatype: replace(): + # replace(): replace(): concat(): could not determine data + # type of placeholder $3. This worked until v24.3 added + # support for non-string data to concat(): + # https://github.com/cockroachdb/cockroach/pull/127098#issuecomment-2492652084 + "model_fields.test_uuid.TestQuerying.test_filter_with_expr", # error in argument for $2: could not parse ":" as type int2: # strconv.ParseInt: parsing ":": invalid syntax # https://github.com/cockroachdb/cockroach/issues/136295 @@ -275,15 +261,6 @@ def django_test_expected_failures(self): # could not parse "@" as type timestamptz: parsing as type timestamp: empty or blank input "aggregation.tests.AggregateTestCase.test_string_agg_order_by", }) - if self.is_cockroachdb_24_3: - expected_failures.update({ - # psycopg.errors.IndeterminateDatatype: replace(): - # replace(): replace(): concat(): could not determine data - # type of placeholder $3. This worked until v24.3 added - # support for non-string data to concat(): - # https://github.com/cockroachdb/cockroach/pull/127098#issuecomment-2492652084 - "model_fields.test_uuid.TestQuerying.test_filter_with_expr", - }) if self.is_cockroachdb_25_1: expected_failures.update({ # psycopg.errors.IndeterminateDatatype: could not determine From 7891e77527b2f1d163825bf5ad3c39f971b8d423 Mon Sep 17 00:00:00 2001 From: Tim Graham Date: Thu, 18 Sep 2025 09:32:34 -0400 Subject: [PATCH 2/2] update for Django 6.1 --- django-test-suite/build.sh | 2 +- django_cockroachdb/__init__.py | 2 +- django_cockroachdb/features.py | 4 ++++ django_cockroachdb/schema.py | 5 ++++- setup.cfg | 2 +- 5 files changed, 11 insertions(+), 4 deletions(-) diff --git a/django-test-suite/build.sh b/django-test-suite/build.sh index 16360d7..caf4dc6 100755 --- a/django-test-suite/build.sh +++ b/django-test-suite/build.sh @@ -7,7 +7,7 @@ VERSION=$1 # clone django into the repo. rm -rf _django_repo -git clone --depth 1 --single-branch --branch cockroach-6.0.x https://github.com/timgraham/django _django_repo +git clone --depth 1 --single-branch --branch cockroach-6.1.x https://github.com/timgraham/django _django_repo # install the django requirements. cd _django_repo/tests/ diff --git a/django_cockroachdb/__init__.py b/django_cockroachdb/__init__.py index c96039c..5f62ae5 100644 --- a/django_cockroachdb/__init__.py +++ b/django_cockroachdb/__init__.py @@ -1,4 +1,4 @@ -__version__ = '6.0' +__version__ = '6.1a0' # Check Django compatibility before other imports which may fail if the # wrong version of Django is installed. diff --git a/django_cockroachdb/features.py b/django_cockroachdb/features.py index 00a6c15..63536a9 100644 --- a/django_cockroachdb/features.py +++ b/django_cockroachdb/features.py @@ -48,6 +48,10 @@ class DatabaseFeatures(PostgresDatabaseFeatures): # https://github.com/cockroachdb/cockroach/issues/95068 supports_comments = False + # CockroachDB doesn't support UNIQUE NULLS NOT DISTINCT: + # https://github.com/cockroachdb/cockroach/issues/115836 + supports_nulls_distinct_unique_constraints = False + @cached_property def introspected_field_types(self): return { diff --git a/django_cockroachdb/schema.py b/django_cockroachdb/schema.py index f081455..ebea10d 100644 --- a/django_cockroachdb/schema.py +++ b/django_cockroachdb/schema.py @@ -18,7 +18,10 @@ class DatabaseSchemaEditor(PostgresDatabaseSchemaEditor): # The PostgreSQL backend uses "SET CONSTRAINTS ... IMMEDIATE" after # creating this foreign key. This isn't supported by CockroachDB. - sql_create_column_inline_fk = 'CONSTRAINT %(name)s REFERENCES %(to_table)s(%(to_column)s)%(deferrable)s' + sql_create_column_inline_fk = ( + 'CONSTRAINT %(name)s REFERENCES %(to_table)s(%(to_column)s)' + '%(on_delete_db)s%(deferrable)s' + ) # The PostgreSQL backend uses "SET CONSTRAINTS ... IMMEDIATE" after this # statement. This isn't supported by CockroachDB. diff --git a/setup.cfg b/setup.cfg index d79a263..e89b12e 100644 --- a/setup.cfg +++ b/setup.cfg @@ -27,7 +27,7 @@ project_urls = python_requires = >=3.12 packages = find: install_requires = - django >= 6.0, < 6.1 +# django >= 6.1, < 6.2 [flake8] max-line-length = 119