Skip to content

Commit 7bbc51f

Browse files
committed
confirm support for CockroachDB 25.1
1 parent f1cef09 commit 7bbc51f

File tree

5 files changed

+42
-17
lines changed

5 files changed

+42
-17
lines changed

.github/workflows/tests.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@ jobs:
4949
use_psycopg2: psycopg2
5050
- crdb-version: v24.3.8
5151
use_server_side_binding: server_side_binding
52+
- crdb-version: v25.1.2
53+
- crdb-version: v25.1.2
54+
use_psycopg2: psycopg2
55+
- crdb-version: v25.1.2
56+
use_server_side_binding: server_side_binding
5257
# Uncomment to enable testing of CockroachDB nightly.
5358
#- crdb-version: LATEST
5459
#- crdb-version: LATEST

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## 5.1.1 - Unreleased
44

5-
- Confirmed support for CockroachDB 24.2.x and 24.3.x (no code changes
5+
- Confirmed support for CockroachDB 24.2.x, 24.3.x, and 25.1.x (no code changes
66
required).
77

88
## 5.1 - 2024-08-13

README.md

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ By default, CockroachDB sends the version of django-cockroachdb that you're
9292
using back to Cockroach Labs. To disable this, set
9393
`DISABLE_COCKROACHDB_TELEMETRY = True` in your Django settings.
9494

95-
## Known issues and limitations in CockroachDB 24.3.x and earlier
95+
## Known issues and limitations in CockroachDB 25.1.x and earlier
9696

9797
- CockroachDB [can't disable constraint checking](https://github.com/cockroachdb/cockroach/issues/19444),
9898
which means certain things in Django like forward references in fixtures
@@ -102,12 +102,6 @@ using back to Cockroach Labs. To disable this, set
102102

103103
- [changing column type if it's part of an index](https://go.crdb.dev/issue/47636)
104104
- dropping or changing a table's primary key
105-
- CockroachDB executes `ALTER COLUMN` queries asynchronously which is at
106-
odds with Django's assumption that the database is altered before the next
107-
migration operation begins. CockroachDB will give an error like
108-
`unimplemented: table <...> is currently undergoing a schema change` if a
109-
later operation tries to modify the table before the asynchronous query
110-
finishes. A future version of CockroachDB [may fix this](https://github.com/cockroachdb/cockroach/issues/47137).
111105

112106
- The `Field.db_comment` and `Meta.db_table_comment` options aren't supported
113107
due to [poor performance](https://github.com/cockroachdb/cockroach/issues/95068).
@@ -145,6 +139,15 @@ using back to Cockroach Labs. To disable this, set
145139
overlaps_below (&>|)](https://github.com/cockroachdb/cockroach/issues/57098)
146140
- [strictly_above (|>>), strictly_below (<<|)](https://github.com/cockroachdb/cockroach/issues/57095)
147141

142+
## Known issues and limitations in CockroachDB 24.3.x and earlier
143+
144+
- CockroachDB executes `ALTER COLUMN` queries asynchronously which is at
145+
odds with Django's assumption that the database is altered before the next
146+
migration operation begins. CockroachDB will give an error like
147+
`unimplemented: table <...> is currently undergoing a schema change` if a
148+
later operation tries to modify the table before the asynchronous query
149+
finishes.
150+
148151
## Known issues and limitations in CockroachDB 23.1.x and earlier
149152

150153
- CockroachDB doesn't support by ordering by JSON.

django_cockroachdb/features.py

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,10 @@ def is_cockroachdb_24_1(self):
8787
def is_cockroachdb_24_3(self):
8888
return self.connection.cockroachdb_version >= (24, 3)
8989

90+
@cached_property
91+
def is_cockroachdb_25_1(self):
92+
return self.connection.cockroachdb_version >= (25, 1)
93+
9094
@cached_property
9195
def django_test_expected_failures(self):
9296
expected_failures = super().django_test_expected_failures
@@ -291,6 +295,12 @@ def django_test_expected_failures(self):
291295
# https://github.com/cockroachdb/cockroach/pull/127098#issuecomment-2492652084
292296
"model_fields.test_uuid.TestQuerying.test_filter_with_expr",
293297
})
298+
if self.is_cockroachdb_25_1:
299+
expected_failures.update({
300+
# psycopg.errors.IndeterminateDatatype: could not determine
301+
# data type of placeholder $1
302+
'expressions_case.tests.CaseExpressionTests.test_filter_with_expression_as_condition',
303+
})
294304
else:
295305
expected_failures.update({
296306
# Unsupported query: unsupported binary operator: <int> / <int>:
@@ -304,13 +314,6 @@ def django_test_expected_failures(self):
304314
def django_test_skips(self):
305315
skips = super().django_test_skips
306316
skips.update({
307-
# https://github.com/cockroachdb/cockroach/issues/47137
308-
# These tests only fail sometimes, e.g.
309-
# https://github.com/cockroachdb/cockroach/issues/65691
310-
'ALTER COLUMN fails if previous asynchronous ALTER COLUMN has not finished.': {
311-
'schema.tests.SchemaTests.test_alter_field_db_collation',
312-
'schema.tests.SchemaTests.test_alter_field_type_and_db_collation',
313-
},
314317
# https://github.com/cockroachdb/django-cockroachdb/issues/153#issuecomment-664697963
315318
'CockroachDB has more restrictive blocking than other databases.': {
316319
'select_for_update.tests.SelectForUpdateTests.test_block',
@@ -341,4 +344,14 @@ def django_test_skips(self):
341344
'admin_views.test_multidb.ViewOnSiteTests.test_contenttype_in_separate_db',
342345
},
343346
})
347+
if not self.is_cockroachdb_25_1:
348+
skips.update({
349+
# https://github.com/cockroachdb/cockroach/issues/47137
350+
# These tests only fail sometimes, e.g.
351+
# https://github.com/cockroachdb/cockroach/issues/65691
352+
'ALTER COLUMN fails if previous asynchronous ALTER COLUMN has not finished.': {
353+
'schema.tests.SchemaTests.test_alter_field_db_collation',
354+
'schema.tests.SchemaTests.test_alter_field_type_and_db_collation',
355+
},
356+
})
344357
return skips

django_cockroachdb/schema.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,12 @@ def _alter_field(self, model, old_field, new_field, old_type, new_type,
5555
old_db_params, new_db_params, strict=False):
5656
# ALTER COLUMN TYPE is experimental.
5757
# https://github.com/cockroachdb/cockroach/issues/49329
58-
if (old_type != new_type or
59-
getattr(old_field, 'db_collation', None) != getattr(new_field, 'db_collation', None)):
58+
if (
59+
not self.connection.features.is_cockroachdb_25_1 and (
60+
old_type != new_type or
61+
getattr(old_field, 'db_collation', None) != getattr(new_field, 'db_collation', None)
62+
)
63+
):
6064
self.execute('SET enable_experimental_alter_column_type_general = true')
6165
# Skip to the base class to avoid trying to add or drop
6266
# PostgreSQL-specific LIKE indexes.

0 commit comments

Comments
 (0)