django-cockroachdb 5.2__tar.gz → 5.2.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (31) hide show
  1. django_cockroachdb-5.2.2/CHANGELOG.md +23 -0
  2. {django-cockroachdb-5.2 → django_cockroachdb-5.2.2}/LICENSE +0 -0
  3. {django-cockroachdb-5.2 → django_cockroachdb-5.2.2}/MANIFEST.in +0 -0
  4. {django-cockroachdb-5.2/django_cockroachdb.egg-info → django_cockroachdb-5.2.2}/PKG-INFO +22 -10
  5. {django-cockroachdb-5.2 → django_cockroachdb-5.2.2}/README.md +18 -8
  6. {django-cockroachdb-5.2 → django_cockroachdb-5.2.2}/django_cockroachdb/__init__.py +3 -3
  7. {django-cockroachdb-5.2 → django_cockroachdb-5.2.2}/django_cockroachdb/base.py +2 -2
  8. {django-cockroachdb-5.2 → django_cockroachdb-5.2.2}/django_cockroachdb/client.py +0 -0
  9. {django-cockroachdb-5.2 → django_cockroachdb-5.2.2}/django_cockroachdb/creation.py +0 -0
  10. {django-cockroachdb-5.2 → django_cockroachdb-5.2.2}/django_cockroachdb/features.py +50 -5
  11. {django-cockroachdb-5.2 → django_cockroachdb-5.2.2}/django_cockroachdb/functions.py +52 -5
  12. {django-cockroachdb-5.2 → django_cockroachdb-5.2.2}/django_cockroachdb/operations.py +0 -0
  13. {django-cockroachdb-5.2 → django_cockroachdb-5.2.2}/django_cockroachdb/schema.py +5 -5
  14. {django-cockroachdb-5.2 → django_cockroachdb-5.2.2}/django_cockroachdb/utils.py +1 -1
  15. {django-cockroachdb-5.2 → django_cockroachdb-5.2.2/django_cockroachdb.egg-info}/PKG-INFO +22 -10
  16. {django-cockroachdb-5.2 → django_cockroachdb-5.2.2}/django_cockroachdb_gis/__init__.py +0 -0
  17. {django-cockroachdb-5.2 → django_cockroachdb-5.2.2}/django_cockroachdb_gis/base.py +0 -0
  18. {django-cockroachdb-5.2 → django_cockroachdb-5.2.2}/django_cockroachdb_gis/features.py +11 -20
  19. {django-cockroachdb-5.2 → django_cockroachdb-5.2.2}/django_cockroachdb_gis/functions.py +0 -0
  20. {django-cockroachdb-5.2 → django_cockroachdb-5.2.2}/django_cockroachdb_gis/introspection.py +0 -0
  21. {django-cockroachdb-5.2 → django_cockroachdb-5.2.2}/django_cockroachdb_gis/operations.py +0 -0
  22. {django-cockroachdb-5.2 → django_cockroachdb-5.2.2}/django_cockroachdb_gis/schema.py +0 -0
  23. {django-cockroachdb-5.2 → django_cockroachdb-5.2.2}/setup.cfg +1 -0
  24. {django-cockroachdb-5.2 → django_cockroachdb-5.2.2}/setup.py +0 -0
  25. django-cockroachdb-5.2/CHANGELOG.md +0 -6
  26. {django-cockroachdb-5.2 → django_cockroachdb-5.2.2}/django_cockroachdb/introspection.py +0 -0
  27. {django-cockroachdb-5.2 → django_cockroachdb-5.2.2}/django_cockroachdb/lookups.py +0 -0
  28. {django-cockroachdb-5.2 → django_cockroachdb-5.2.2}/django_cockroachdb.egg-info/SOURCES.txt +0 -0
  29. {django-cockroachdb-5.2 → django_cockroachdb-5.2.2}/django_cockroachdb.egg-info/dependency_links.txt +0 -0
  30. {django-cockroachdb-5.2 → django_cockroachdb-5.2.2}/django_cockroachdb.egg-info/requires.txt +0 -0
  31. {django-cockroachdb-5.2 → django_cockroachdb-5.2.2}/django_cockroachdb.egg-info/top_level.txt +0 -0
@@ -0,0 +1,23 @@
1
+ # Changelog
2
+
3
+ ## 5.2.2 - 2026-08-07
4
+
5
+ - Confirmed support for CockroachDB 26.1.x and 26.2.x (no code changes
6
+ required).
7
+ - Added support for CockroachDB 26.3.x. This version of CockroachDB reports
8
+ itself as PostgreSQL 18 (increased from version 13 in prior versions).
9
+ Several Django feature flags are adjusted to account for behavioral
10
+ differences between PostgreSQL and CockroachDB to maintain correct behavior.
11
+
12
+ ## 5.2.1 - 2025-12-04
13
+
14
+ - Confirmed support for CockroachDB 25.2.x, 25.3.x, and 25.4.x (no code changes
15
+ required).
16
+ - Fixed the ``Now`` database function to use the statement time
17
+ (``STATEMENT_TIMESTAMP``) rather than the transaction time
18
+ (``CURRENT_TIMESTAMP``).
19
+
20
+ ## 5.2 - 2025-04-07
21
+
22
+ Initial release for Django 5.2.x and CockroachDB 23.2.x, 24.1.x, 24.3.x, and
23
+ 25.1.x.
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
2
  Name: django-cockroachdb
3
- Version: 5.2
3
+ Version: 5.2.2
4
4
  Summary: Django backend for CockroachDB
5
5
  Home-page: https://github.com/cockroachdb/django-cockroachdb
6
6
  Maintainer: Cockroach Labs
@@ -19,10 +19,12 @@ Classifier: Programming Language :: Python :: 3.10
19
19
  Classifier: Programming Language :: Python :: 3.11
20
20
  Classifier: Programming Language :: Python :: 3.12
21
21
  Classifier: Programming Language :: Python :: 3.13
22
+ Classifier: Programming Language :: Python :: 3.14
22
23
  Requires-Python: >=3.10
23
24
  Description-Content-Type: text/markdown
24
25
  License-File: LICENSE
25
26
  Requires-Dist: django<6.0,>=5.2
27
+ Dynamic: license-file
26
28
 
27
29
  # CockroachDB backend for Django
28
30
 
@@ -118,7 +120,7 @@ By default, CockroachDB sends the version of django-cockroachdb that you're
118
120
  using back to Cockroach Labs. To disable this, set
119
121
  `DISABLE_COCKROACHDB_TELEMETRY = True` in your Django settings.
120
122
 
121
- ## Known issues and limitations in CockroachDB 25.1.x and earlier
123
+ ## Known issues and limitations in CockroachDB 26.3.x and earlier
122
124
 
123
125
  - CockroachDB [can't disable constraint checking](https://github.com/cockroachdb/cockroach/issues/19444),
124
126
  which means certain things in Django like forward references in fixtures
@@ -132,11 +134,13 @@ using back to Cockroach Labs. To disable this, set
132
134
  - The `Field.db_comment` and `Meta.db_table_comment` options aren't supported
133
135
  due to [poor performance](https://github.com/cockroachdb/cockroach/issues/95068).
134
136
 
137
+ - The `AnyValue` database function [isn't supported](https://github.com/cockroachdb/cockroach/issues/172590).
138
+
139
+ - `UniqueConstraint.nulls_distinct` [isn't supported](https://github.com/cockroachdb/cockroach/issues/115836).
140
+
135
141
  - Unsupported queries:
136
142
  - [Mixed type addition in SELECT](https://github.com/cockroachdb/django-cockroachdb/issues/19):
137
143
  `unsupported binary operator: <int> + <float>`
138
- - [Division that yields a different type](https://github.com/cockroachdb/django-cockroachdb/issues/21):
139
- `unsupported binary operator: <int> / <int> (desired <int>)`
140
144
  - [The power() database function doesn't accept negative exponents](https://github.com/cockroachdb/django-cockroachdb/issues/22):
141
145
  `power(): integer out of range`
142
146
  - [sum() doesn't support arguments of different types](https://github.com/cockroachdb/django-cockroachdb/issues/73):
@@ -148,15 +152,12 @@ using back to Cockroach Labs. To disable this, set
148
152
  - GIS:
149
153
  - Some database functions aren't supported: `AsGML`, `AsKML`, `AsSVG`,
150
154
  and `GeometryDistance`.
151
- - Some 3D functions or signatures aren't supported: `ST_3DPerimeter`,
152
- `ST_3DExtent`, `ST_Scale`, and `ST_LengthSpheroid`.
155
+ - Some 3D functions or signatures aren't supported: `ST_3DExtent`,
156
+ `ST_Scale`, and `ST_LengthSpheroid`.
153
157
  - The `Length` database function isn't supported on geodetic fields:
154
158
  [st_lengthspheroid(): unimplemented](https://github.com/cockroachdb/cockroach/issues/48968).
155
159
  - `Union` may crash with
156
160
  [unknown signature: st_union(geometry, geometry)](https://github.com/cockroachdb/cockroach/issues/49064).
157
- - The spheroid argument of ST_DistanceSpheroid
158
- [isn't supported](https://github.com/cockroachdb/cockroach/issues/48922):
159
- `unknown signature: st_distancespheroid(geometry, geometry, string)`.
160
161
  - These lookups aren't supported:
161
162
  - [contained (@)](https://github.com/cockroachdb/cockroach/issues/56124)
162
163
  - [exact/same_as (~=)](https://github.com/cockroachdb/cockroach/issues/57096)
@@ -165,6 +166,17 @@ using back to Cockroach Labs. To disable this, set
165
166
  overlaps_below (&>|)](https://github.com/cockroachdb/cockroach/issues/57098)
166
167
  - [strictly_above (|>>), strictly_below (<<|)](https://github.com/cockroachdb/cockroach/issues/57095)
167
168
 
169
+ ## Known issues and limitations in CockroachDB 26.2.x and earlier
170
+
171
+ - GIS:
172
+ - The `ST_3DPerimeter` function [isn't supported](https://github.com/cockroachdb/cockroach/issues/60871).
173
+ - The spheroid argument of `ST_DistanceSpheroid`
174
+ [isn't supported](https://github.com/cockroachdb/cockroach/issues/48922).
175
+
176
+ - Queries which use [division that yields a different
177
+ type](https://github.com/cockroachdb/django-cockroachdb/issues/21) aren't
178
+ supported: `unsupported binary operator: <int> / <int> (desired <int>)`
179
+
168
180
  ## Known issues and limitations in CockroachDB 24.3.x and earlier
169
181
 
170
182
  - CockroachDB executes `ALTER COLUMN` queries asynchronously which is at
@@ -92,7 +92,7 @@ By default, CockroachDB sends the version of django-cockroachdb that you're
92
92
  using back to Cockroach Labs. To disable this, set
93
93
  `DISABLE_COCKROACHDB_TELEMETRY = True` in your Django settings.
94
94
 
95
- ## Known issues and limitations in CockroachDB 25.1.x and earlier
95
+ ## Known issues and limitations in CockroachDB 26.3.x and earlier
96
96
 
97
97
  - CockroachDB [can't disable constraint checking](https://github.com/cockroachdb/cockroach/issues/19444),
98
98
  which means certain things in Django like forward references in fixtures
@@ -106,11 +106,13 @@ using back to Cockroach Labs. To disable this, set
106
106
  - The `Field.db_comment` and `Meta.db_table_comment` options aren't supported
107
107
  due to [poor performance](https://github.com/cockroachdb/cockroach/issues/95068).
108
108
 
109
+ - The `AnyValue` database function [isn't supported](https://github.com/cockroachdb/cockroach/issues/172590).
110
+
111
+ - `UniqueConstraint.nulls_distinct` [isn't supported](https://github.com/cockroachdb/cockroach/issues/115836).
112
+
109
113
  - Unsupported queries:
110
114
  - [Mixed type addition in SELECT](https://github.com/cockroachdb/django-cockroachdb/issues/19):
111
115
  `unsupported binary operator: <int> + <float>`
112
- - [Division that yields a different type](https://github.com/cockroachdb/django-cockroachdb/issues/21):
113
- `unsupported binary operator: <int> / <int> (desired <int>)`
114
116
  - [The power() database function doesn't accept negative exponents](https://github.com/cockroachdb/django-cockroachdb/issues/22):
115
117
  `power(): integer out of range`
116
118
  - [sum() doesn't support arguments of different types](https://github.com/cockroachdb/django-cockroachdb/issues/73):
@@ -122,15 +124,12 @@ using back to Cockroach Labs. To disable this, set
122
124
  - GIS:
123
125
  - Some database functions aren't supported: `AsGML`, `AsKML`, `AsSVG`,
124
126
  and `GeometryDistance`.
125
- - Some 3D functions or signatures aren't supported: `ST_3DPerimeter`,
126
- `ST_3DExtent`, `ST_Scale`, and `ST_LengthSpheroid`.
127
+ - Some 3D functions or signatures aren't supported: `ST_3DExtent`,
128
+ `ST_Scale`, and `ST_LengthSpheroid`.
127
129
  - The `Length` database function isn't supported on geodetic fields:
128
130
  [st_lengthspheroid(): unimplemented](https://github.com/cockroachdb/cockroach/issues/48968).
129
131
  - `Union` may crash with
130
132
  [unknown signature: st_union(geometry, geometry)](https://github.com/cockroachdb/cockroach/issues/49064).
131
- - The spheroid argument of ST_DistanceSpheroid
132
- [isn't supported](https://github.com/cockroachdb/cockroach/issues/48922):
133
- `unknown signature: st_distancespheroid(geometry, geometry, string)`.
134
133
  - These lookups aren't supported:
135
134
  - [contained (@)](https://github.com/cockroachdb/cockroach/issues/56124)
136
135
  - [exact/same_as (~=)](https://github.com/cockroachdb/cockroach/issues/57096)
@@ -139,6 +138,17 @@ using back to Cockroach Labs. To disable this, set
139
138
  overlaps_below (&>|)](https://github.com/cockroachdb/cockroach/issues/57098)
140
139
  - [strictly_above (|>>), strictly_below (<<|)](https://github.com/cockroachdb/cockroach/issues/57095)
141
140
 
141
+ ## Known issues and limitations in CockroachDB 26.2.x and earlier
142
+
143
+ - GIS:
144
+ - The `ST_3DPerimeter` function [isn't supported](https://github.com/cockroachdb/cockroach/issues/60871).
145
+ - The spheroid argument of `ST_DistanceSpheroid`
146
+ [isn't supported](https://github.com/cockroachdb/cockroach/issues/48922).
147
+
148
+ - Queries which use [division that yields a different
149
+ type](https://github.com/cockroachdb/django-cockroachdb/issues/21) aren't
150
+ supported: `unsupported binary operator: <int> / <int> (desired <int>)`
151
+
142
152
  ## Known issues and limitations in CockroachDB 24.3.x and earlier
143
153
 
144
154
  - CockroachDB executes `ALTER COLUMN` queries asynchronously which is at
@@ -1,10 +1,10 @@
1
- __version__ = '5.2'
1
+ __version__ = '5.2.2'
2
2
 
3
3
  # Check Django compatibility before other imports which may fail if the
4
4
  # wrong version of Django is installed.
5
- from .utils import check_django_compatability
5
+ from .utils import check_django_compatibility
6
6
 
7
- check_django_compatability()
7
+ check_django_compatibility()
8
8
 
9
9
  from .functions import register_functions # noqa
10
10
  from .lookups import patch_lookups # noqa
@@ -81,7 +81,7 @@ class DatabaseWrapper(PostgresDatabaseWrapper):
81
81
  determine if rows with invalid references were entered while constraint
82
82
  checks were off.
83
83
  """
84
- # cockroachdb doesn't support disabling constraint checking
84
+ # CockroachDB doesn't support disabling constraint checking
85
85
  # (https://github.com/cockroachdb/cockroach/issues/19444) so this
86
86
  # method is a no-op.
87
87
  pass
@@ -91,7 +91,7 @@ class DatabaseWrapper(PostgresDatabaseWrapper):
91
91
 
92
92
  @contextmanager
93
93
  def _nodb_cursor(self):
94
- # Overidden to avoid inapplicable "Django was unable to create a
94
+ # Overridden to avoid inapplicable "Django was unable to create a
95
95
  # connection to the 'postgres' database and will use the first
96
96
  # PostgreSQL database instead." warning.
97
97
  with super(PostgresDatabaseWrapper, self)._nodb_cursor() as cursor:
@@ -29,11 +29,11 @@ class DatabaseFeatures(PostgresDatabaseFeatures):
29
29
  # due to use of DEFAULT unique_rowid().
30
30
  supports_sequence_reset = False
31
31
 
32
- # Forward references in fixtures won't work until cockroachdb can
32
+ # Forward references in fixtures won't work until CockroachDB can
33
33
  # disable constraints: https://github.com/cockroachdb/cockroach/issues/19444
34
34
  supports_forward_references = False
35
35
 
36
- # Unlike PostgreSQL, cockroachdb doesn't support any EXPLAIN formats
36
+ # Unlike PostgreSQL, CockroachDB doesn't support any EXPLAIN formats
37
37
  # ('JSON', 'TEXT', 'XML', and 'YAML').
38
38
  supported_explain_formats = set()
39
39
 
@@ -48,6 +48,12 @@ class DatabaseFeatures(PostgresDatabaseFeatures):
48
48
  # https://github.com/cockroachdb/cockroach/issues/95068
49
49
  supports_comments = False
50
50
 
51
+ # Not supported: https://github.com/cockroachdb/cockroach/issues/172590
52
+ supports_any_value = False
53
+
54
+ # Not supported: https://github.com/cockroachdb/cockroach/issues/115836
55
+ supports_nulls_distinct_unique_constraints = False
56
+
51
57
  @cached_property
52
58
  def introspected_field_types(self):
53
59
  return {
@@ -87,6 +93,22 @@ class DatabaseFeatures(PostgresDatabaseFeatures):
87
93
  def is_cockroachdb_25_1(self):
88
94
  return self.connection.cockroachdb_version >= (25, 1)
89
95
 
96
+ @cached_property
97
+ def is_cockroachdb_25_2(self):
98
+ return self.connection.cockroachdb_version >= (25, 2)
99
+
100
+ @cached_property
101
+ def is_cockroachdb_25_4(self):
102
+ return self.connection.cockroachdb_version >= (25, 4)
103
+
104
+ @cached_property
105
+ def is_cockroachdb_26_1(self):
106
+ return self.connection.cockroachdb_version >= (26, 1)
107
+
108
+ @cached_property
109
+ def is_cockroachdb_26_3(self):
110
+ return self.connection.cockroachdb_version >= (26, 3)
111
+
90
112
  @cached_property
91
113
  def django_test_expected_failures(self):
92
114
  expected_failures = super().django_test_expected_failures
@@ -264,14 +286,17 @@ class DatabaseFeatures(PostgresDatabaseFeatures):
264
286
  'db_functions.text.test_concat.ConcatTests.test_concat_non_str',
265
287
  # unsupported binary operator: <interval> / <decimal>
266
288
  'expressions.tests.FTimeDeltaTests.test_durationfield_multiply_divide',
267
- # InvalidParameterValue: unsupported binary operator: <int4> / <float>
268
- 'queries.tests.Ticket23605Tests.test_ticket_23605',
269
289
  # InvalidParameterValue: unsupported binary operator: <int2> + <float>
270
290
  'annotations.tests.NonAggregateAnnotationTestCase.test_combined_annotation_commutative',
271
291
  # incompatible COALESCE expressions: unsupported binary
272
292
  # operator: <decimal> / <float> (desired <decimal>)
273
293
  'aggregation.tests.AggregateTestCase.test_aggregation_default_passed_another_aggregate',
274
294
  })
295
+ if not self.is_cockroachdb_26_3:
296
+ expected_failures.update({
297
+ # InvalidParameterValue: unsupported binary operator: <int4> / <float>
298
+ 'queries.tests.Ticket23605Tests.test_ticket_23605',
299
+ })
275
300
  if self.is_cockroachdb_24_3:
276
301
  expected_failures.update({
277
302
  # psycopg.errors.IndeterminateDatatype: replace():
@@ -287,7 +312,19 @@ class DatabaseFeatures(PostgresDatabaseFeatures):
287
312
  # data type of placeholder $1
288
313
  'expressions_case.tests.CaseExpressionTests.test_filter_with_expression_as_condition',
289
314
  })
290
- else:
315
+ if self.is_cockroachdb_25_2:
316
+ expected_failures.update({
317
+ # concat(): error type checking resolved expression::
318
+ # could not determine data type of placeholder $1
319
+ 'aggregation_regress.tests.AggregationTests.test_aggregate_group_by_unseen_columns_unmanaged',
320
+ 'db_functions.text.test_concat.ConcatTests.test_many',
321
+ 'db_functions.text.test_concat.ConcatTests.test_mixed_char_text',
322
+ 'db_functions.text.test_replace.ReplaceTests.test_replace_expression',
323
+ 'expressions.tests.BasicExpressionsTests.test_slicing_of_f_expression_with_annotated_expression',
324
+ 'filtered_relation.tests.FilteredRelationTests.test_condition_with_func_and_lookup_outside_relation_name', # noqa
325
+ 'select_for_update.tests.SelectForUpdateTests.test_for_update_of_values_list',
326
+ })
327
+ elif not self.is_cockroachdb_26_3:
291
328
  expected_failures.update({
292
329
  # Unsupported query: unsupported binary operator: <int> / <int>:
293
330
  # https://github.com/cockroachdb/django-cockroachdb/issues/21
@@ -340,4 +377,12 @@ class DatabaseFeatures(PostgresDatabaseFeatures):
340
377
  'schema.tests.SchemaTests.test_alter_field_type_and_db_collation',
341
378
  },
342
379
  })
380
+ if self.is_cockroachdb_25_4 and not self.is_cockroachdb_26_1:
381
+ skips.update({
382
+ # Error truncating hundreds of tables:
383
+ # https://github.com/cockroachdb/cockroach/issues/156682
384
+ 'Test fails when run with all apps.': {
385
+ 'migration_test_data_persistence.tests.MigrationDataPersistenceClassSetup',
386
+ },
387
+ })
343
388
  return skips
@@ -1,12 +1,12 @@
1
1
  import datetime
2
2
 
3
3
  from django.db.models import (
4
- DateTimeField, DecimalField, FloatField, IntegerField,
4
+ DateTimeField, DecimalField, FloatField, IntegerField, TextField,
5
5
  )
6
6
  from django.db.models.expressions import When
7
7
  from django.db.models.functions import (
8
8
  ACos, ASin, ATan, ATan2, Cast, Ceil, Coalesce, Collate, Cos, Cot, Degrees,
9
- Exp, Floor, JSONArray, JSONObject, Ln, Log, Radians, Round, Sin, Sqrt,
9
+ Exp, Floor, JSONArray, JSONObject, Ln, Log, Now, Radians, Round, Sin, Sqrt,
10
10
  StrIndex, Tan,
11
11
  )
12
12
 
@@ -36,7 +36,7 @@ def collate(self, compiler, connection, **extra_context):
36
36
 
37
37
 
38
38
  def float_cast(self, compiler, connection, **extra_context):
39
- # Most cockroachdb math functions require float arguments instead of
39
+ # Most CockroachDB math functions require float arguments instead of
40
40
  # decimal or integer.
41
41
  clone = self.copy()
42
42
  clone.set_source_expressions([
@@ -46,6 +46,52 @@ def float_cast(self, compiler, connection, **extra_context):
46
46
  return clone.as_sql(compiler, connection, **extra_context)
47
47
 
48
48
 
49
+ def json_array(self, compiler, connection, **extra_context):
50
+ # Django uses json_array() for PostgreSQL 16+. CockroachDB 26.3+ reports
51
+ # itself as PostgreSQL 18 but doesn't support it:
52
+ # https://github.com/cockroachdb/cockroach/issues/172633.
53
+ # When it does, this function can be removed.
54
+ casted_obj = self.copy()
55
+ casted_obj.set_source_expressions(
56
+ [
57
+ (
58
+ # Conditional Cast to avoid unnecessary wrapping.
59
+ expression
60
+ if isinstance(expression, Cast)
61
+ else Cast(expression, expression.output_field)
62
+ )
63
+ for expression in casted_obj.get_source_expressions()
64
+ ]
65
+ )
66
+ return casted_obj.as_sql(
67
+ compiler,
68
+ connection,
69
+ function="JSONB_BUILD_ARRAY",
70
+ **extra_context,
71
+ )
72
+
73
+
74
+ def json_object(self, compiler, connection, **extra_context):
75
+ # Django uses json_object([{ key_expression { VALUE | ':' }
76
+ # value_expression }]) for PostgreSQL 16+. CockroachDB 26.3+ reports itself
77
+ # as PostgreSQL 18 but doesn't support it:
78
+ # https://github.com/cockroachdb/cockroach/issues/172638.
79
+ # When it does, this function can be removed.
80
+ copy = self.copy()
81
+ copy.set_source_expressions(
82
+ [
83
+ Cast(expression, TextField()) if index % 2 == 0 else expression
84
+ for index, expression in enumerate(copy.get_source_expressions())
85
+ ]
86
+ )
87
+ return super(JSONObject, copy).as_sql(
88
+ compiler,
89
+ connection,
90
+ function="JSONB_BUILD_OBJECT",
91
+ **extra_context,
92
+ )
93
+
94
+
49
95
  def round_cast(self, compiler, connection, **extra_context):
50
96
  # ROUND() doesn't accept integer values. Cast to decimal (rather than
51
97
  # float) so that half away from zero rounding is used, consistent with
@@ -77,8 +123,9 @@ def register_functions():
77
123
  func.as_cockroachdb = float_cast
78
124
  Coalesce.as_cockroachdb = coalesce
79
125
  Collate.as_cockroachdb = collate
80
- JSONArray.as_cockroachdb = JSONArray.as_postgresql
81
- JSONObject.as_cockroachdb = JSONObject.as_postgresql
126
+ JSONArray.as_cockroachdb = json_array
127
+ JSONObject.as_cockroachdb = json_object
128
+ Now.as_cockroachdb = Now.as_postgresql
82
129
  Round.as_cockroachdb = round_cast
83
130
  StrIndex.as_cockroachdb = StrIndex.as_postgresql
84
131
  When.as_cockroachdb = when
@@ -8,8 +8,8 @@ from django.db.models import ForeignKey
8
8
 
9
9
  class DatabaseSchemaEditor(PostgresDatabaseSchemaEditor):
10
10
  # The PostgreSQL backend uses "SET CONSTRAINTS ... IMMEDIATE" before
11
- # "ALTER TABLE..." to run any any deferred checks to allow dropping the
12
- # foreign key in the same transaction. This doesn't apply to cockroachdb.
11
+ # "ALTER TABLE..." to run any deferred checks to allow dropping the foreign
12
+ # key in the same transaction. This doesn't apply to CockroachDB.
13
13
  sql_delete_fk = "ALTER TABLE %(table)s DROP CONSTRAINT %(name)s"
14
14
 
15
15
  # "ALTER TABLE ... DROP CONSTRAINT ..." not supported for dropping UNIQUE
@@ -44,11 +44,11 @@ class DatabaseSchemaEditor(PostgresDatabaseSchemaEditor):
44
44
  super().remove_index(model, index, concurrently)
45
45
 
46
46
  def _index_columns(self, table, columns, col_suffixes, opclasses):
47
- # cockroachdb doesn't support PostgreSQL opclasses.
47
+ # CockroachDB doesn't support PostgreSQL opclasses.
48
48
  return BaseDatabaseSchemaEditor._index_columns(self, table, columns, col_suffixes, opclasses)
49
49
 
50
50
  def _create_like_index_sql(self, model, field):
51
- # cockroachdb doesn't support LIKE indexes.
51
+ # CockroachDB doesn't support LIKE indexes.
52
52
  return None
53
53
 
54
54
  def _alter_field(self, model, old_field, new_field, old_type, new_type,
@@ -118,5 +118,5 @@ class DatabaseSchemaEditor(PostgresDatabaseSchemaEditor):
118
118
  )
119
119
 
120
120
  def _field_should_be_indexed(self, model, field):
121
- # Foreign keys are automatically indexed by cockroachdb.
121
+ # Foreign keys are automatically indexed by CockroachDB.
122
122
  return not isinstance(field, ForeignKey) and super()._field_should_be_indexed(model, field)
@@ -3,7 +3,7 @@ from django.core.exceptions import ImproperlyConfigured
3
3
  from django.utils.version import get_version_tuple
4
4
 
5
5
 
6
- def check_django_compatability():
6
+ def check_django_compatibility():
7
7
  """
8
8
  Verify that this version of django-cockroachdb is compatible with the
9
9
  installed version of Django. For example, any django-cockroachdb 2.2.x is
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
2
  Name: django-cockroachdb
3
- Version: 5.2
3
+ Version: 5.2.2
4
4
  Summary: Django backend for CockroachDB
5
5
  Home-page: https://github.com/cockroachdb/django-cockroachdb
6
6
  Maintainer: Cockroach Labs
@@ -19,10 +19,12 @@ Classifier: Programming Language :: Python :: 3.10
19
19
  Classifier: Programming Language :: Python :: 3.11
20
20
  Classifier: Programming Language :: Python :: 3.12
21
21
  Classifier: Programming Language :: Python :: 3.13
22
+ Classifier: Programming Language :: Python :: 3.14
22
23
  Requires-Python: >=3.10
23
24
  Description-Content-Type: text/markdown
24
25
  License-File: LICENSE
25
26
  Requires-Dist: django<6.0,>=5.2
27
+ Dynamic: license-file
26
28
 
27
29
  # CockroachDB backend for Django
28
30
 
@@ -118,7 +120,7 @@ By default, CockroachDB sends the version of django-cockroachdb that you're
118
120
  using back to Cockroach Labs. To disable this, set
119
121
  `DISABLE_COCKROACHDB_TELEMETRY = True` in your Django settings.
120
122
 
121
- ## Known issues and limitations in CockroachDB 25.1.x and earlier
123
+ ## Known issues and limitations in CockroachDB 26.3.x and earlier
122
124
 
123
125
  - CockroachDB [can't disable constraint checking](https://github.com/cockroachdb/cockroach/issues/19444),
124
126
  which means certain things in Django like forward references in fixtures
@@ -132,11 +134,13 @@ using back to Cockroach Labs. To disable this, set
132
134
  - The `Field.db_comment` and `Meta.db_table_comment` options aren't supported
133
135
  due to [poor performance](https://github.com/cockroachdb/cockroach/issues/95068).
134
136
 
137
+ - The `AnyValue` database function [isn't supported](https://github.com/cockroachdb/cockroach/issues/172590).
138
+
139
+ - `UniqueConstraint.nulls_distinct` [isn't supported](https://github.com/cockroachdb/cockroach/issues/115836).
140
+
135
141
  - Unsupported queries:
136
142
  - [Mixed type addition in SELECT](https://github.com/cockroachdb/django-cockroachdb/issues/19):
137
143
  `unsupported binary operator: <int> + <float>`
138
- - [Division that yields a different type](https://github.com/cockroachdb/django-cockroachdb/issues/21):
139
- `unsupported binary operator: <int> / <int> (desired <int>)`
140
144
  - [The power() database function doesn't accept negative exponents](https://github.com/cockroachdb/django-cockroachdb/issues/22):
141
145
  `power(): integer out of range`
142
146
  - [sum() doesn't support arguments of different types](https://github.com/cockroachdb/django-cockroachdb/issues/73):
@@ -148,15 +152,12 @@ using back to Cockroach Labs. To disable this, set
148
152
  - GIS:
149
153
  - Some database functions aren't supported: `AsGML`, `AsKML`, `AsSVG`,
150
154
  and `GeometryDistance`.
151
- - Some 3D functions or signatures aren't supported: `ST_3DPerimeter`,
152
- `ST_3DExtent`, `ST_Scale`, and `ST_LengthSpheroid`.
155
+ - Some 3D functions or signatures aren't supported: `ST_3DExtent`,
156
+ `ST_Scale`, and `ST_LengthSpheroid`.
153
157
  - The `Length` database function isn't supported on geodetic fields:
154
158
  [st_lengthspheroid(): unimplemented](https://github.com/cockroachdb/cockroach/issues/48968).
155
159
  - `Union` may crash with
156
160
  [unknown signature: st_union(geometry, geometry)](https://github.com/cockroachdb/cockroach/issues/49064).
157
- - The spheroid argument of ST_DistanceSpheroid
158
- [isn't supported](https://github.com/cockroachdb/cockroach/issues/48922):
159
- `unknown signature: st_distancespheroid(geometry, geometry, string)`.
160
161
  - These lookups aren't supported:
161
162
  - [contained (@)](https://github.com/cockroachdb/cockroach/issues/56124)
162
163
  - [exact/same_as (~=)](https://github.com/cockroachdb/cockroach/issues/57096)
@@ -165,6 +166,17 @@ using back to Cockroach Labs. To disable this, set
165
166
  overlaps_below (&>|)](https://github.com/cockroachdb/cockroach/issues/57098)
166
167
  - [strictly_above (|>>), strictly_below (<<|)](https://github.com/cockroachdb/cockroach/issues/57095)
167
168
 
169
+ ## Known issues and limitations in CockroachDB 26.2.x and earlier
170
+
171
+ - GIS:
172
+ - The `ST_3DPerimeter` function [isn't supported](https://github.com/cockroachdb/cockroach/issues/60871).
173
+ - The spheroid argument of `ST_DistanceSpheroid`
174
+ [isn't supported](https://github.com/cockroachdb/cockroach/issues/48922).
175
+
176
+ - Queries which use [division that yields a different
177
+ type](https://github.com/cockroachdb/django-cockroachdb/issues/21) aren't
178
+ supported: `unsupported binary operator: <int> / <int> (desired <int>)`
179
+
168
180
  ## Known issues and limitations in CockroachDB 24.3.x and earlier
169
181
 
170
182
  - CockroachDB executes `ALTER COLUMN` queries asynchronously which is at
@@ -1,7 +1,6 @@
1
1
  from django.contrib.gis.db.backends.postgis.features import (
2
2
  DatabaseFeatures as PostGISFeatures,
3
3
  )
4
- from django.db.backends.postgresql.psycopg_any import is_psycopg3
5
4
  from django.utils.functional import cached_property
6
5
 
7
6
  from django_cockroachdb.features import DatabaseFeatures as CockroachFeatures
@@ -9,8 +8,6 @@ from django_cockroachdb.features import DatabaseFeatures as CockroachFeatures
9
8
 
10
9
  class DatabaseFeatures(CockroachFeatures, PostGISFeatures):
11
10
  supports_raster = False
12
- # Not supported: https://github.com/cockroachdb/cockroach/issues/57092
13
- supports_left_right_lookups = False
14
11
  # unimplemented: column point is of type geometry and thus is not indexable
15
12
  # https://go.crdb.dev/issue/35730
16
13
  supports_geometry_field_unique_index = False
@@ -30,6 +27,7 @@ class DatabaseFeatures(CockroachFeatures, PostGISFeatures):
30
27
  'gis_tests.relatedapp.tests.RelatedGeoModelTest.test06_f_expressions',
31
28
  # unknown signature: st_union(geometry, geometry)
32
29
  # https://github.com/cockroachdb/cockroach/issues/49064
30
+ 'gis_tests.distapp.tests.DistanceTest.test_distance_lookups_with_expression_rhs',
33
31
  'gis_tests.distapp.tests.DistanceTest.test_dwithin',
34
32
  'gis_tests.geoapp.test_functions.GISFunctionsTests.test_diff_intersection_union',
35
33
  'gis_tests.geoapp.test_functions.GISFunctionsTests.test_union_mixed_srid',
@@ -38,20 +36,12 @@ class DatabaseFeatures(CockroachFeatures, PostGISFeatures):
38
36
  'gis_tests.geoapp.tests.GeoLookupTest.test_relate_lookup',
39
37
  # NotSupportedError: this box2d comparison operator is experimental
40
38
  'gis_tests.geoapp.tests.GeoLookupTest.test_contains_contained_lookups',
41
- # unknown signature: st_distancespheroid(geometry, geometry, string)
42
- # https://github.com/cockroachdb/cockroach/issues/48922#issuecomment-693096502
43
- 'gis_tests.distapp.tests.DistanceTest.test_distance_lookups_with_expression_rhs',
44
- 'gis_tests.distapp.tests.DistanceTest.test_geodetic_distance_lookups',
45
- 'gis_tests.distapp.tests.DistanceFunctionsTests.test_distance_geodetic_spheroid',
46
39
  # st_lengthspheroid(): unimplemented:
47
40
  # https://github.com/cockroachdb/cockroach/issues/48968
48
41
  'gis_tests.distapp.tests.DistanceFunctionsTests.test_length',
49
42
  # Unsupported ~= (https://github.com/cockroachdb/cockroach/issues/57096)
50
43
  # and @ operators (https://github.com/cockroachdb/cockroach/issues/56124).
51
44
  'gis_tests.geogapp.tests.GeographyTest.test_operators_functions_unavailable_for_geography',
52
- # unknown function: st_3dperimeter
53
- # https://github.com/cockroachdb/cockroach/issues/60871
54
- 'gis_tests.geo3d.tests.Geo3DFunctionsTests.test_perimeter',
55
45
  # unknown function: st_3dextent()
56
46
  # https://github.com/cockroachdb/cockroach/issues/60864
57
47
  'gis_tests.geo3d.tests.Geo3DTest.test_extent',
@@ -74,15 +64,6 @@ class DatabaseFeatures(CockroachFeatures, PostGISFeatures):
74
64
  # https://github.com/cockroachdb/cockroach/issues/47420#issuecomment-969578772
75
65
  'gis_tests.gis_migrations.test_operations.OperationTests.test_add_3d_field_opclass',
76
66
  })
77
- if is_psycopg3 and not self.is_cockroachdb_24_1:
78
- expected_failures.update({
79
- # QuerySet.bulk_create() doesn't work with geometries after
80
- # https://github.com/django/django/commit/a16eedcf9c69d8a11d94cac1811018c5b996d491
81
- # could not parse geometry: error parsing EWKB hex: encoding/hex:
82
- # invalid byte: U+003A ':'
83
- # https://github.com/cockroachdb/cockroach/issues/138140
84
- 'gis_tests.geoapp.test_functions.GISFunctionsTests.test_area_lookups',
85
- })
86
67
  if self.uses_server_side_binding:
87
68
  expected_failures.update({
88
69
  # unknown signature: st_scale(geometry, int, int)
@@ -94,4 +75,14 @@ class DatabaseFeatures(CockroachFeatures, PostGISFeatures):
94
75
  # https://github.com/cockroachdb/cockroach/issues/53720
95
76
  'gis_tests.geogapp.tests.GeographyTest.test02_distance_lookup',
96
77
  })
78
+ if not self.is_cockroachdb_26_3:
79
+ expected_failures.update({
80
+ # unknown signature: st_distancespheroid(geometry, geometry, string)
81
+ # https://github.com/cockroachdb/cockroach/issues/48922#issuecomment-693096502
82
+ 'gis_tests.distapp.tests.DistanceTest.test_geodetic_distance_lookups',
83
+ 'gis_tests.distapp.tests.DistanceFunctionsTests.test_distance_geodetic_spheroid',
84
+ # unknown function: st_3dperimeter
85
+ # https://github.com/cockroachdb/cockroach/issues/60871
86
+ 'gis_tests.geo3d.tests.Geo3DFunctionsTests.test_perimeter',
87
+ })
97
88
  return expected_failures
@@ -20,6 +20,7 @@ classifiers =
20
20
  Programming Language :: Python :: 3.11
21
21
  Programming Language :: Python :: 3.12
22
22
  Programming Language :: Python :: 3.13
23
+ Programming Language :: Python :: 3.14
23
24
  project_urls =
24
25
  Source = https://github.com/cockroachdb/django-cockroachdb
25
26
  Tracker = https://github.com/cockroachdb/django-cockroachdb/issues
@@ -1,6 +0,0 @@
1
- # Changelog
2
-
3
- ## 5.2 - 2025-04-07
4
-
5
- Initial release for Django 5.2.x and CockroachDB 23.2.x, 24.1.x, 24.3.x, and
6
- 25.1.x.