Skip to content

Commit

Permalink
confirm support for CockroachDB 25.1
Browse files Browse the repository at this point in the history
  • Loading branch information
timgraham committed Dec 31, 2024
1 parent 00c9e2a commit a140006
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 21 deletions.
15 changes: 10 additions & 5 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,17 @@ jobs:
use_psycopg2: psycopg2
- crdb-version: v24.3.2
use_server_side_binding: server_side_binding
- crdb-version: v25.1.0-alpha.1
- crdb-version: v25.1.0-alpha.1
use_psycopg2: psycopg2
- crdb-version: v25.1.0-alpha.1
use_server_side_binding: server_side_binding
# Uncomment to enable testing of CockroachDB nightly.
#- crdb-version: LATEST
#- crdb-version: LATEST
# use_psycopg2: psycopg2
#- crdb-version: LATEST
# use_server_side_binding: server_side_binding
- crdb-version: LATEST
- crdb-version: LATEST
use_psycopg2: psycopg2
- crdb-version: LATEST
use_server_side_binding: server_side_binding
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
Expand Down
17 changes: 10 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ By default, CockroachDB sends the version of django-cockroachdb that you're
using back to Cockroach Labs. To disable this, set
`DISABLE_COCKROACHDB_TELEMETRY = True` in your Django settings.

## Known issues and limitations in CockroachDB 24.3.x and earlier
## Known issues and limitations in CockroachDB 25.1.x and earlier

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

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

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

## Known issues and limitations in CockroachDB 24.3.x and earlier

- CockroachDB executes `ALTER COLUMN` queries asynchronously which is at
odds with Django's assumption that the database is altered before the next
migration operation begins. CockroachDB will give an error like
`unimplemented: table <...> is currently undergoing a schema change` if a
later operation tries to modify the table before the asynchronous query
finishes.

## Known issues and limitations in CockroachDB 23.1.x and earlier

- CockroachDB doesn't support by ordering by JSON.
25 changes: 18 additions & 7 deletions django_cockroachdb/features.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ def is_cockroachdb_24_1(self):
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 >= (24, 3)

@cached_property
def django_test_expected_failures(self):
expected_failures = super().django_test_expected_failures
Expand Down Expand Up @@ -291,6 +295,10 @@ def django_test_expected_failures(self):
# 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({
'expressions_case.tests.CaseExpressionTests.test_filter_with_expression_as_condition',
})
else:
expected_failures.update({
# Unsupported query: unsupported binary operator: <int> / <int>:
Expand All @@ -304,13 +312,6 @@ def django_test_expected_failures(self):
def django_test_skips(self):
skips = super().django_test_skips
skips.update({
# https://github.com/cockroachdb/cockroach/issues/47137
# These tests only fail sometimes, e.g.
# https://github.com/cockroachdb/cockroach/issues/65691
'ALTER COLUMN fails if previous asynchronous ALTER COLUMN has not finished.': {
'schema.tests.SchemaTests.test_alter_field_db_collation',
'schema.tests.SchemaTests.test_alter_field_type_and_db_collation',
},
# https://github.com/cockroachdb/django-cockroachdb/issues/153#issuecomment-664697963
'CockroachDB has more restrictive blocking than other databases.': {
'select_for_update.tests.SelectForUpdateTests.test_block',
Expand Down Expand Up @@ -341,4 +342,14 @@ def django_test_skips(self):
'admin_views.test_multidb.ViewOnSiteTests.test_contenttype_in_separate_db',
},
})
if not self.is_cockroachdb_25_1:
skips.update({
# https://github.com/cockroachdb/cockroach/issues/47137
# These tests only fail sometimes, e.g.
# https://github.com/cockroachdb/cockroach/issues/65691
'ALTER COLUMN fails if previous asynchronous ALTER COLUMN has not finished.': {
'schema.tests.SchemaTests.test_alter_field_db_collation',
'schema.tests.SchemaTests.test_alter_field_type_and_db_collation',
},
})
return skips
8 changes: 6 additions & 2 deletions django_cockroachdb/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,12 @@ def _alter_field(self, model, old_field, new_field, old_type, new_type,
old_db_params, new_db_params, strict=False):
# ALTER COLUMN TYPE is experimental.
# https://github.com/cockroachdb/cockroach/issues/49329
if (old_type != new_type or
getattr(old_field, 'db_collation', None) != getattr(new_field, 'db_collation', None)):
if (
not self.connection.features.is_cockroachdb_25_1 and (
old_type != new_type or
getattr(old_field, 'db_collation', None) != getattr(new_field, 'db_collation', None)
)
):
self.execute('SET enable_experimental_alter_column_type_general = true')
# Skip to the base class to avoid trying to add or drop
# PostgreSQL-specific LIKE indexes.
Expand Down

0 comments on commit a140006

Please sign in to comment.