diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index b83c5db7..54172098 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -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: @@ -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 diff --git a/CHANGELOG.md b/CHANGELOG.md index f2c6bebc..7d300d12 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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. diff --git a/README.md b/README.md index 8392ec86..4a6fe7fc 100644 --- a/README.md +++ b/README.md @@ -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. @@ -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. diff --git a/django-test-suite/build.sh b/django-test-suite/build.sh index b62d91c8..08cff7ac 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-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/ diff --git a/django_cockroachdb/__init__.py b/django_cockroachdb/__init__.py index 1af3e3f5..1afef5b6 100644 --- a/django_cockroachdb/__init__.py +++ b/django_cockroachdb/__init__.py @@ -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. diff --git a/django_cockroachdb/features.py b/django_cockroachdb/features.py index cb192fb3..19ae8386 100644 --- a/django_cockroachdb/features.py +++ b/django_cockroachdb/features.py @@ -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 @@ -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) @@ -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 @@ -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', @@ -197,32 +198,10 @@ 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 ) - 'migrations.test_operations.OperationTests.test_add_generate_field', + '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', }) - 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: > : - # 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({ @@ -230,12 +209,19 @@ def django_test_expected_failures(self): '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', diff --git a/django_cockroachdb/functions.py b/django_cockroachdb/functions.py index de99ba03..8f0d3ebd 100644 --- a/django_cockroachdb/functions.py +++ b/django_cockroachdb/functions.py @@ -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, ) @@ -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 diff --git a/django_cockroachdb_gis/features.py b/django_cockroachdb_gis/features.py index 24de0706..f415ed01 100644 --- a/django_cockroachdb_gis/features.py +++ b/django_cockroachdb_gis/features.py @@ -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 @@ -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) diff --git a/django_cockroachdb_gis/schema.py b/django_cockroachdb_gis/schema.py index 53d7492f..f6600c2a 100644 --- a/django_cockroachdb_gis/schema.py +++ b/django_cockroachdb_gis/schema.py @@ -5,5 +5,5 @@ ) -class DatabaseSchemaEditor(CockroachSchemaEditor, PostGISSchemaEditor): +class DatabaseSchemaEditor(PostGISSchemaEditor, CockroachSchemaEditor): pass diff --git a/setup.cfg b/setup.cfg index 251bae0f..99f64662 100644 --- a/setup.cfg +++ b/setup.cfg @@ -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 @@ -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