Skip to content

Commit 38587e3

Browse files
committed
dep: support Django 5.1, update clickhouse-driver to 0.2.9
1 parent df4e58a commit 38587e3

File tree

13 files changed

+29
-527
lines changed

13 files changed

+29
-527
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
### unreleased
1+
### 1.3.1
22

33
- fix: #99 update value containing "where" cause exception.
44
- fix: #97 JSONField error in ClickHouse 24.8.
55
- fix: tuple function error in ClickHouse 24.8.
6+
- support Django 5.1, update clickhouse-driver to 0.2.9.
67

78
### 1.3.0
89

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Django ClickHouse Database Backend
99
[![Coverage Status](https://coveralls.io/repos/github/jayvynl/django-clickhouse-backend/badge.svg?branch=main)](https://coveralls.io/github/jayvynl/django-clickhouse-backend?branch=main)
1010
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
1111

12-
Django clickhouse backend is a [django database backend](https://docs.djangoproject.com/en/4.1/ref/databases/) for
12+
Django clickhouse backend is a [django database backend](https://docs.djangoproject.com/en/5.1/ref/databases/) for
1313
[clickhouse](https://clickhouse.com/docs/en/home/) database. This project allows using django ORM to interact with
1414
clickhouse, the goal of the project is to operate clickhouse like operating mysql, postgresql in django.
1515

@@ -152,7 +152,7 @@ class ClickHouseRouter:
152152
return None
153153
```
154154

155-
You should use [database router](https://docs.djangoproject.com/en/4.1/topics/db/multi-db/#automatic-database-routing) to
155+
You should use [database router](https://docs.djangoproject.com/en/5.1/topics/db/multi-db/#automatic-database-routing) to
156156
automatically route your queries to the right database. In the preceding example, I write a database router which route all
157157
queries from subclasses of `clickhouse_backend.models.ClickhouseModel` or custom migrations with a `clickhouse` hint key to clickhouse.
158158
All other queries are routed to the default database (postgresql).

clickhouse_backend/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from clickhouse_backend.utils.version import get_version
22

3-
VERSION = (1, 3, 0, "final", 0)
3+
VERSION = (1, 3, 1, "final", 0)
44

55
__version__ = get_version(VERSION)

clickhouse_backend/backend/schema.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -211,9 +211,8 @@ def _model_indexes_sql(self, model):
211211
"Refer to https://clickhouse.com/docs/en/engines/table-engines/"
212212
"mergetree-family/mergetree/#table_engine-mergetree-data_skipping-indexes"
213213
)
214-
if (
215-
any(field.db_index for field in model._meta.local_fields)
216-
or getattr(model._meta, "index_together", None)
214+
if any(field.db_index for field in model._meta.local_fields) or getattr(
215+
model._meta, "index_together", None
217216
):
218217
warnings.warn(msg)
219218

docs/Fields.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ Clickhouse backend support django builtin fields and clickhouse specific fields.
66
**Note:** You should always use clickhouse specific fields in new projects.
77
Support for django built-in fields is only for compatibility with existing third-party apps.
88

9-
**Note:** [ForeignKey](https://docs.djangoproject.com/en/4.1/ref/models/fields/#foreignkey), [ManyToManyField](https://docs.djangoproject.com/en/4.1/ref/models/fields/#manytomanyfield)
10-
or even [OneToOneField](https://docs.djangoproject.com/en/4.1/ref/models/fields/#onetoonefield) could be used with clickhouse backend.
9+
**Note:** [ForeignKey](https://docs.djangoproject.com/en/5.1/ref/models/fields/#foreignkey), [ManyToManyField](https://docs.djangoproject.com/en/5.1/ref/models/fields/#manytomanyfield)
10+
or even [OneToOneField](https://docs.djangoproject.com/en/5.1/ref/models/fields/#onetoonefield) could be used with clickhouse backend.
1111
But no database level constraints will be added, so there could be some consistency problems.
1212

1313

@@ -171,9 +171,9 @@ DATABASES = {
171171

172172
Fields importing path: `clickhouse_backend.models.Date[32]Field`
173173

174-
[Dates query](https://docs.djangoproject.com/en/4.1/ref/models/querysets/#dates) is supported by DateField and Date32Field.
174+
[Dates query](https://docs.djangoproject.com/en/5.1/ref/models/querysets/#dates) is supported by DateField and Date32Field.
175175

176-
All [date lookup](https://docs.djangoproject.com/en/4.1/ref/models/querysets/#date) are supported by DateField and Date32Field.
176+
All [date lookup](https://docs.djangoproject.com/en/5.1/ref/models/querysets/#date) are supported by DateField and Date32Field.
177177

178178
Both Nullable and LowCardinality are supported.
179179

@@ -206,10 +206,10 @@ Fields importing path: `clickhouse_backend.models.DateTime[64]Field`
206206

207207
DateTime64Field have a [`precision`](https://clickhouse.com/docs/en/sql-reference/data-types/datetime64) parameter which default to 6.
208208

209-
[Dates query](https://docs.djangoproject.com/en/4.1/ref/models/querysets/#dates) and [datetimes query](https://docs.djangoproject.com/en/4.1/ref/models/querysets/#datetimes)
209+
[Dates query](https://docs.djangoproject.com/en/5.1/ref/models/querysets/#dates) and [datetimes query](https://docs.djangoproject.com/en/5.1/ref/models/querysets/#datetimes)
210210
are supported by DateTimeField and DateTime64Field.
211211

212-
All [date lookup](https://docs.djangoproject.com/en/4.1/ref/models/querysets/#date) are supported by DateTimeField and DateTime64Field.
212+
All [date lookup](https://docs.djangoproject.com/en/5.1/ref/models/querysets/#date) are supported by DateTimeField and DateTime64Field.
213213

214214
Both Nullable and LowCardinality are supported by DateTime. But LowCardinality is not supported by DateTime64.
215215

pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ classifiers = [
2020
"Framework :: Django :: 4.1",
2121
"Framework :: Django :: 4.2",
2222
"Framework :: Django :: 5.0",
23+
"Framework :: Django :: 5.1",
2324
"Intended Audience :: Developers",
2425
"License :: OSI Approved :: MIT License",
2526
"Programming Language :: Python",
@@ -34,7 +35,7 @@ classifiers = [
3435
]
3536
dependencies = [
3637
"django>=3.2",
37-
"clickhouse-driver==0.2.8",
38+
"clickhouse-driver==0.2.9",
3839
]
3940
dynamic = ["version", "readme"]
4041

tests/aggregation/tests.py

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1106,25 +1106,6 @@ def as_sql(self, compiler, connection):
11061106
):
11071107
Book.objects.annotate(Max("id")).annotate(my_max=MyMax("id__max", "price"))
11081108

1109-
def test_multi_arg_aggregate(self):
1110-
class MyMax(Max):
1111-
output_field = DecimalField()
1112-
1113-
def as_sql(self, compiler, connection):
1114-
copy = self.copy()
1115-
copy.set_source_expressions(copy.get_source_expressions()[0:1])
1116-
return super(MyMax, copy).as_sql(compiler, connection)
1117-
1118-
with self.assertRaisesMessage(TypeError, "Complex aggregates require an alias"):
1119-
Book.objects.aggregate(MyMax("pages", "price"))
1120-
1121-
with self.assertRaisesMessage(
1122-
TypeError, "Complex annotations require an alias"
1123-
):
1124-
Book.objects.annotate(MyMax("pages", "price"))
1125-
1126-
Book.objects.aggregate(max_field=MyMax("pages", "price"))
1127-
11281109
def test_add_implementation(self):
11291110
class MySum(Sum):
11301111
pass

tests/expressions_window/tests.py

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1157,28 +1157,3 @@ def test_invalid_type_start_value_range(self):
11571157
)
11581158
)
11591159
)
1160-
1161-
def test_invalid_type_end_row_range(self):
1162-
msg = "end argument must be a positive integer, zero, or None, but got 'a'."
1163-
with self.assertRaisesMessage(ValueError, msg):
1164-
list(
1165-
Employee.objects.annotate(
1166-
test=Window(
1167-
expression=Sum("salary"),
1168-
frame=RowRange(end="a"),
1169-
)
1170-
)
1171-
)
1172-
1173-
def test_invalid_type_start_row_range(self):
1174-
msg = "start argument must be a negative integer, zero, or None, but got 'a'."
1175-
with self.assertRaisesMessage(ValueError, msg):
1176-
list(
1177-
Employee.objects.annotate(
1178-
test=Window(
1179-
expression=Sum("salary"),
1180-
order_by=F("hire_date").asc(),
1181-
frame=RowRange(start="a"),
1182-
)
1183-
)
1184-
)

0 commit comments

Comments
 (0)