Skip to content

Commit cfae1ef

Browse files
committed
drop support for CockroachDB 21.2.x
1 parent 98edd32 commit cfae1ef

File tree

4 files changed

+2
-70
lines changed

4 files changed

+2
-70
lines changed

README.md

-5
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,3 @@ using back to Cockroach Labs. To disable this, set
140140
## Known issues and limitations in CockroachDB 22.1.x and earlier
141141

142142
- `QuerySet.select_for_update(skip_locked=True)` isn't supported.
143-
144-
## Known issues and limitations in CockroachDB 21.2.x and earlier
145-
146-
- Unsupported query: [UPDATE float column with integer column](https://github.com/cockroachdb/django-cockroachdb/issues/20):
147-
`value type int doesn't match type FLOAT8 of column <name>`

django_cockroachdb/features.py

+1-27
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88

99
class DatabaseFeatures(PostgresDatabaseFeatures):
10-
minimum_database_version = (21, 2)
10+
minimum_database_version = (22, 1)
1111

1212
# Cloning databases doesn't speed up tests.
1313
# https://github.com/cockroachdb/django-cockroachdb/issues/206
@@ -60,8 +60,6 @@ def introspected_field_types(self):
6060
'SmallAutoField': 'SmallIntegerField',
6161
}
6262

63-
supports_order_by_nulls_modifier = property(operator.attrgetter('is_cockroachdb_22_1'))
64-
6563
# CockroachDB doesn't create indexes on foreign keys.
6664
indexes_foreign_keys = False
6765

@@ -76,10 +74,6 @@ def introspected_field_types(self):
7674
'swedish_ci': 'sv-x-icu',
7775
}
7876

79-
@cached_property
80-
def is_cockroachdb_22_1(self):
81-
return self.connection.cockroachdb_version >= (22, 1)
82-
8377
@cached_property
8478
def is_cockroachdb_22_2(self):
8579
return self.connection.cockroachdb_version >= (22, 2)
@@ -197,19 +191,6 @@ def django_test_expected_failures(self):
197191
# https://github.com/cockroachdb/cockroach/issues/73587#issuecomment-988408190
198192
'aggregation.tests.AggregateTestCase.test_aggregation_default_using_decimal_from_database',
199193
})
200-
if not self.connection.features.is_cockroachdb_22_1:
201-
expected_failures.update({
202-
# ProgrammingError: value type float doesn't match type decimal of
203-
# column "n2":
204-
# INSERT INTO "db_functions_decimalmodel" ("n1", "n2") VALUES ( -5.75, PI())
205-
'db_functions.math.test_round.RoundTests.test_decimal_with_precision',
206-
# Passing a naive datetime to cursor.execute() doesn't work in
207-
# older versions of CockroachDB.
208-
'timezones.tests.LegacyDatabaseTests.test_cursor_execute_accepts_naive_datetime',
209-
# unknown signature: date_trunc(string, interval):
210-
# https://github.com/cockroachdb/cockroach/issues/76960
211-
'db_functions.datetime.test_extract_trunc.DateFunctionTests.test_extract_second_func_no_fractional',
212-
})
213194
return expected_failures
214195

215196
@cached_property
@@ -249,11 +230,4 @@ def django_test_skips(self):
249230
'get_or_create.tests.UpdateOrCreateTransactionTests.test_updates_in_transaction',
250231
},
251232
})
252-
if not self.connection.features.is_cockroachdb_22_1:
253-
skips.update({
254-
# https://github.com/cockroachdb/django-cockroachdb/issues/20
255-
'Unsupported query: UPDATE float column with integer column.': {
256-
'expressions.tests.ExpressionsNumericTests',
257-
},
258-
})
259233
return skips

django_cockroachdb/operations.py

-37
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
1-
import time
2-
31
from django.db.backends.base.base import timezone_constructor
42
from django.db.backends.postgresql.operations import (
53
DatabaseOperations as PostgresDatabaseOperations,
64
)
7-
from django.db.utils import OperationalError
8-
from psycopg2 import errorcodes
95

106

117
class DatabaseOperations(PostgresDatabaseOperations):
@@ -22,23 +18,6 @@ class DatabaseOperations(PostgresDatabaseOperations):
2218
}
2319
explain_options = frozenset(['DISTSQL', 'OPT', 'TYPES', 'VEC', 'VERBOSE'])
2420

25-
def datetime_extract_sql(self, lookup_type, sql, params, tzname):
26-
if self.connection.features.is_cockroachdb_22_1:
27-
return super().datetime_extract_sql(lookup_type, sql, params, tzname)
28-
# Override the changes from https://github.com/django/django/commit/b7f263551c64e3f80544892e314ed5b0b22cc7c8
29-
# which aren't compatible with older versions of CockroachDB:
30-
# https://github.com/cockroachdb/cockroach/issues/76960
31-
sql, params = self._convert_sql_to_tz(sql, params, tzname)
32-
return self.date_extract_sql(lookup_type, sql, params)
33-
34-
def time_extract_sql(self, lookup_type, sql, params):
35-
if self.connection.features.is_cockroachdb_22_1:
36-
return super().time_extract_sql(lookup_type, sql, params)
37-
# Override the changes from https://github.com/django/django/commit/b7f263551c64e3f80544892e314ed5b0b22cc7c8
38-
# which aren't compatible with older versions of CockroachDB:
39-
# https://github.com/cockroachdb/cockroach/issues/76960
40-
return self.date_extract_sql(lookup_type, sql, params)
41-
4221
def deferrable_sql(self):
4322
# Deferrable constraints aren't supported:
4423
# https://github.com/cockroachdb/cockroach/issues/31632
@@ -79,22 +58,6 @@ def explain_query_prefix(self, format=None, **options):
7958
prefix += ' (%s)' % ', '.join(extra)
8059
return prefix
8160

82-
def execute_sql_flush(self, sql_list):
83-
# Retry TRUNCATE if it fails with a serialization error.
84-
num_retries = 10
85-
initial_retry_delay = 0.5 # The initial retry delay, in seconds.
86-
backoff_ = 1.5 # For each retry, the last delay is multiplied by this.
87-
next_retry_delay = initial_retry_delay
88-
for retry in range(1, num_retries + 1):
89-
try:
90-
return super().execute_sql_flush(sql_list)
91-
except OperationalError as exc:
92-
if (getattr(exc.__cause__, 'pgcode', '') != errorcodes.SERIALIZATION_FAILURE or
93-
retry >= num_retries):
94-
raise
95-
time.sleep(next_retry_delay)
96-
next_retry_delay *= backoff_
97-
9861
def sql_flush(self, style, tables, *, reset_sequences=False, allow_cascade=False):
9962
# CockroachDB doesn't support resetting sequences.
10063
return super().sql_flush(style, tables, reset_sequences=False, allow_cascade=allow_cascade)

teamcity-build/build-teamcity-21.2.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#!/usr/bin/env bash
22
set -x
33

4-
./teamcity-build/build-teamcity.sh "v21.2.17"
4+
# Not supported

0 commit comments

Comments
 (0)