Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 2 additions & 7 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
# This job aggregates all matrix results and is used for a GitHub required status check.
test_results:
if: ${{ always() }}
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
name: Test Results
needs: [test]
steps:
Expand All @@ -24,16 +24,11 @@ jobs:
fi

test:
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
strategy:
fail-fast: false
matrix:
include:
- crdb-version: v23.1.30
- crdb-version: v23.1.30
use_psycopg2: psycopg2
- crdb-version: v23.1.30
use_server_side_binding: server_side_binding
- crdb-version: v23.2.21
- crdb-version: v23.2.21
use_psycopg2: psycopg2
Expand Down
10 changes: 3 additions & 7 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
# Changelog

## 5.1.1 - Unreleased
## 5.2 - 2025-04-07

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

## 5.1 - 2024-08-13

Initial release for Django 5.1.x and CockroachDB 23.1.x, 23.2.x, and 24.1.x.
Initial release for Django 5.2.x and CockroachDB 23.2.x, 24.1.x, 24.3.x, and
25.1.x.
8 changes: 2 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ production it is advised to use the package built from sources.
## Install and usage

Use the version of django-cockroachdb that corresponds to your version of
Django. For example, to get the latest compatible release for Django 5.1.x:
Django. For example, to get the latest compatible release for Django 5.2.x:

`pip install django-cockroachdb==5.1.*`
`pip install django-cockroachdb==5.2.*`

The minor release number of Django doesn't correspond to the minor release
number of django-cockroachdb. Use the latest minor release of each.
Expand Down Expand Up @@ -147,7 +147,3 @@ using back to Cockroach Labs. To disable this, set
`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.
2 changes: 1 addition & 1 deletion django-test-suite/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ VERSION=$1

# clone django into the repo.
rm -rf _django_repo
git clone --depth 1 --single-branch --branch cockroach-5.1.x https://github.com/timgraham/django _django_repo
git clone --depth 1 --single-branch --branch cockroach-5.2.x https://github.com/timgraham/django _django_repo

# install the django requirements.
cd _django_repo/tests/
Expand Down
2 changes: 1 addition & 1 deletion django_cockroachdb/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = '5.1'
__version__ = '5.2'

# Check Django compatibility before other imports which may fail if the
# wrong version of Django is installed.
Expand Down
42 changes: 14 additions & 28 deletions django_cockroachdb/features.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@


class DatabaseFeatures(PostgresDatabaseFeatures):
minimum_database_version = (23, 1)
minimum_database_version = (23, 2)

# Cloning databases doesn't speed up tests.
# https://github.com/cockroachdb/django-cockroachdb/issues/206
Expand Down Expand Up @@ -75,10 +75,6 @@ def introspected_field_types(self):
'virtual': None,
}

@cached_property
def is_cockroachdb_23_2(self):
return self.connection.cockroachdb_version >= (23, 2)

@cached_property
def is_cockroachdb_24_1(self):
return self.connection.cockroachdb_version >= (24, 1)
Expand Down Expand Up @@ -154,6 +150,10 @@ def django_test_expected_failures(self):
'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',
# unimplemented: primary key dropped without subsequent addition of
# new primary key in same transaction
# https://github.com/cockroachdb/cockroach/issues/48026
'migrations.test_operations.OperationTests.test_composite_pk_operations',
# CockroachDB doesn't support changing the primary key of table.
# psycopg.errors.InvalidColumnReference: column "id" is referenced
# by the primary key
Expand All @@ -169,6 +169,7 @@ def django_test_expected_failures(self):
'many_to_one.tests.ManyToOneTests.test_get_prefetch_querysets_reverse_invalid_querysets_length',
'migrations.test_operations.OperationTests.test_smallfield_autofield_foreignfield_growth',
'migrations.test_operations.OperationTests.test_smallfield_bigautofield_foreignfield_growth',
'schema.tests.SchemaTests.test_alter_smallint_pk_to_smallautofield_pk',
# unexpected unique index in pg_constraint query:
# https://github.com/cockroachdb/cockroach/issues/61098
'introspection.tests.IntrospectionTests.test_get_constraints_unique_indexes_orders',
Expand Down Expand Up @@ -197,45 +198,30 @@ def django_test_expected_failures(self):
'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 <string>)
'migrations.test_operations.OperationTests.test_add_generate_field',
'migrations.test_operations.OperationTests.test_add_generated_field',
# concat(): unknown signature: concat(string, int2) (desired <string>)
'db_functions.text.test_concat.ConcatTests.test_concat_non_str',
})
if not self.is_cockroachdb_23_2:
expected_failures.update({
# cannot index a json element:
# https://github.com/cockroachdb/cockroach/issues/35706
'schema.tests.SchemaTests.test_func_index_json_key_transform',
# ordering by JSON isn't supported:
# https://github.com/cockroachdb/cockroach/issues/35706
'db_functions.comparison.test_json_object.JSONObjectTests.test_order_by_key',
'db_functions.comparison.test_json_object.JSONObjectTests.test_order_by_nested_key',
'expressions_window.tests.WindowFunctionTests.test_key_transform',
'model_fields.test_jsonfield.TestQuerying.test_deep_distinct',
'model_fields.test_jsonfield.TestQuerying.test_order_grouping_custom_decoder',
'model_fields.test_jsonfield.TestQuerying.test_ordering_by_transform',
'model_fields.test_jsonfield.TestQuerying.test_ordering_grouping_by_key_transform',
# unsupported comparison operator: <jsonb> > <string>:
# https://github.com/cockroachdb/cockroach/issues/49144
'model_fields.test_jsonfield.TestQuerying.test_deep_lookup_transform',
# DataError: incompatible COALESCE expressions: expected pi() to be
# of type decimal, found type float
# https://github.com/cockroachdb/cockroach/issues/73587#issuecomment-988408190
'aggregation.tests.AggregateTestCase.test_aggregation_default_using_decimal_from_database',
})
if self.is_cockroachdb_24_1:
# USING cast required: https://github.com/cockroachdb/cockroach/issues/82416#issuecomment-2029803229
expected_failures.update({
'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',
})
if self.is_cockroachdb_25_1:
expected_failures.update({
# expected STORED COMPUTED COLUMN expression to have type
# decimal, but 'pink + pink' has type int
'migrations.test_operations.OperationTests.test_generated_field_changes_output_field',
})
if self.uses_server_side_binding:
expected_failures.update({
# could not determine data type of placeholder:
# https://github.com/cockroachdb/cockroach/issues/91396
'backends.tests.EscapingChecks.test_parameter_escaping',
'backends.tests.EscapingChecksDebug.test_parameter_escaping',
'composite_pk.test_update.CompositePKUpdateTests.test_bulk_update_comments',
'constraints.tests.CheckConstraintTests.test_database_default',
'expressions.tests.BasicExpressionsTests.test_annotate_values_filter',
'expressions_case.tests.CaseDocumentationExamples.test_lookup_example',
Expand Down
4 changes: 3 additions & 1 deletion django_cockroachdb/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
from django.db.models.expressions import When
from django.db.models.functions import (
ACos, ASin, ATan, ATan2, Cast, Ceil, Coalesce, Collate, Cos, Cot, Degrees,
Exp, Floor, JSONObject, Ln, Log, Radians, Round, Sin, Sqrt, StrIndex, Tan,
Exp, Floor, JSONArray, JSONObject, Ln, Log, Radians, Round, Sin, Sqrt,
StrIndex, Tan,
)


Expand Down Expand Up @@ -76,6 +77,7 @@ def register_functions():
func.as_cockroachdb = float_cast
Coalesce.as_cockroachdb = coalesce
Collate.as_cockroachdb = collate
JSONArray.as_cockroachdb = JSONArray.as_postgresql
JSONObject.as_cockroachdb = JSONObject.as_postgresql
Round.as_cockroachdb = round_cast
StrIndex.as_cockroachdb = StrIndex.as_postgresql
Expand Down
11 changes: 11 additions & 0 deletions django_cockroachdb_gis/features.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from django.contrib.gis.db.backends.postgis.features import (
DatabaseFeatures as PostGISFeatures,
)
from django.db.backends.postgresql.psycopg_any import is_psycopg3
from django.utils.functional import cached_property

from django_cockroachdb.features import DatabaseFeatures as CockroachFeatures
Expand Down Expand Up @@ -68,10 +69,20 @@ def django_test_expected_failures(self):
# data is currently not supported for columns that are part of an
# index: https://github.com/cockroachdb/cockroach/issues/47636
'gis_tests.gis_migrations.test_operations.OperationTests.test_alter_geom_field_dim',
'gis_tests.gis_migrations.test_operations.OperationTests.test_alter_field_with_spatial_index',
# 3D opclass not present on CockroachDB:
# https://github.com/cockroachdb/cockroach/issues/47420#issuecomment-969578772
'gis_tests.gis_migrations.test_operations.OperationTests.test_add_3d_field_opclass',
})
if is_psycopg3 and not self.is_cockroachdb_24_1:
expected_failures.update({
# QuerySet.bulk_create() doesn't work with geometries after
# https://github.com/django/django/commit/a16eedcf9c69d8a11d94cac1811018c5b996d491
# could not parse geometry: error parsing EWKB hex: encoding/hex:
# invalid byte: U+003A ':'
# https://github.com/cockroachdb/cockroach/issues/138140
'gis_tests.geoapp.test_functions.GISFunctionsTests.test_area_lookups',
})
if self.uses_server_side_binding:
expected_failures.update({
# unknown signature: st_scale(geometry, int, int)
Expand Down
2 changes: 1 addition & 1 deletion django_cockroachdb_gis/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
)


class DatabaseSchemaEditor(CockroachSchemaEditor, PostGISSchemaEditor):
class DatabaseSchemaEditor(PostGISSchemaEditor, CockroachSchemaEditor):
pass
4 changes: 2 additions & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ long_description_content_type = text/markdown
classifiers =
Development Status :: 5 - Production/Stable
Framework :: Django
Framework :: Django :: 5.1
Framework :: Django :: 5.2
License :: OSI Approved :: Apache Software License
Operating System :: OS Independent
Programming Language :: Python
Expand All @@ -28,7 +28,7 @@ project_urls =
python_requires = >=3.10
packages = find:
install_requires =
django >= 5.1, < 5.2
django >= 5.2, < 6.0

[flake8]
max-line-length = 119
Expand Down