From 5fe375c9a46412d7d6f2c9339eed132a610e3654 Mon Sep 17 00:00:00 2001 From: Lin Zhiwen Date: Thu, 5 Jun 2025 01:56:59 +0800 Subject: [PATCH] feat: Django 5.2 Support #122 --- .github/workflows/base-test.yml | 2 +- CHANGELOG.md | 1 + clickhouse_backend/__init__.py | 2 +- clickhouse_backend/models/sql/compiler.py | 21 --------------------- pyproject.toml | 1 + tests/aggregation/tests.py | 2 ++ tox.ini | 7 ++++++- 7 files changed, 12 insertions(+), 24 deletions(-) diff --git a/.github/workflows/base-test.yml b/.github/workflows/base-test.yml index f6c4e24..9bed06f 100644 --- a/.github/workflows/base-test.yml +++ b/.github/workflows/base-test.yml @@ -13,7 +13,7 @@ jobs: fail-fast: false matrix: python-version: ["3.10", "3.13"] - django-version: ["3.2", "4.0", "4.1", "4.2", "5.0", "5.1"] + django-version: ["3.2", "4.0", "4.1", "4.2", "5.0", "5.1", "5.2"] clickhouse-version: ["23.8", "latest"] include: - python-version: "3.7" diff --git a/CHANGELOG.md b/CHANGELOG.md index 5401934..1569e7d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ - feat: #119 Allow query results returned in columns and deserialized to `numpy` objects - feat: #125 Add database functions `toStartOfMinute`, `toStartOfFiveMinutes`, `toStartOfTenMinutes`, `toStartOfFifteenMinutes` and `toStartofHour` +- feat: #122 Django 5.2 Support ### 1.3.2 diff --git a/clickhouse_backend/__init__.py b/clickhouse_backend/__init__.py index ce59bb6..7b9b417 100644 --- a/clickhouse_backend/__init__.py +++ b/clickhouse_backend/__init__.py @@ -1,5 +1,5 @@ from clickhouse_backend.utils.version import get_version -VERSION = (1, 3, 2, "final", 0) +VERSION = (1, 4, 0, "final", 0) __version__ = get_version(VERSION) diff --git a/clickhouse_backend/models/sql/compiler.py b/clickhouse_backend/models/sql/compiler.py index e54b801..a0569b8 100644 --- a/clickhouse_backend/models/sql/compiler.py +++ b/clickhouse_backend/models/sql/compiler.py @@ -286,27 +286,6 @@ def as_sql(self, with_limits=True, with_col_aliases=False): class SQLInsertCompiler(compiler.SQLInsertCompiler): - def field_as_sql(self, field, val): - """ - Take a field and a value intended to be saved on that field, and - return placeholder SQL and accompanying params. Check for raw values, - expressions, and fields with get_placeholder() defined in that order. - - When field is None, consider the value raw and use it as the - placeholder, with no corresponding parameters returned. - """ - if field is None: - # A field value of None means the value is raw. - sql, params = val, [] - elif hasattr(val, "as_sql"): - # This is an expression, let's compile it. - sql, params = self.compile(val) - else: - # Return the common case for the placeholder - sql, params = "%s", [val] - - return sql, params - def as_sql(self): # We don't need quote_name_unless_alias() here, since these are all # going to be column names (so we can avoid the extra overhead). diff --git a/pyproject.toml b/pyproject.toml index 73f3cc7..6bda6cf 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -22,6 +22,7 @@ classifiers = [ "Framework :: Django :: 5", "Framework :: Django :: 5.0", "Framework :: Django :: 5.1", + "Framework :: Django :: 5.2", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Programming Language :: Python", diff --git a/tests/aggregation/tests.py b/tests/aggregation/tests.py index f20674f..245cf56 100644 --- a/tests/aggregation/tests.py +++ b/tests/aggregation/tests.py @@ -1097,6 +1097,8 @@ def test_annotated_aggregate_over_annotated_aggregate(self): Book.objects.annotate(Max("id")).annotate(Sum("id__max")) class MyMax(Max): + arity = None + def as_sql(self, compiler, connection): self.set_source_expressions(self.get_source_expressions()[0:1]) return super().as_sql(compiler, connection) diff --git a/tox.ini b/tox.ini index a7761ac..b783624 100644 --- a/tox.ini +++ b/tox.ini @@ -1,7 +1,11 @@ [tox] requires = tox>=4 -env_list = py3.7-django3.2, py{3.8,3.9}-django{3.2,4.0,4.1,4.2}, py{3.10,3.11,3.12}-django{3.2,4.0,4.1,4.2,5.0,5.1}, py3.13-django{4.1,4.2,5.0,5.1} +env_list = + py3.7-django3.2 + py{3.8,3.9}-django{3.2,4.0,4.1,4.2} + py{3.10,3.11,3.12}-django{3.2,4.0,4.1,4.2,5.0,5.1,5.2} + py3.13-django{4.1,4.2,5.0,5.1,5.2} [variables] code = clickhouse_backend example tests @@ -14,6 +18,7 @@ deps = django4.2: Django>=4.2,<5.0 django5.0: Django>=5.0,<5.1 django5.1: Django>=5.1,<5.2 + django5.2: Django>=5.2,<5.3 coverage commands = pip install pandas