Skip to content

Commit

Permalink
Add Django-5.0 support #143
Browse files Browse the repository at this point in the history
  • Loading branch information
shimizukawa committed Jul 27, 2024
1 parent 88090a3 commit b63286c
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test-examples-proj1.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
max-parallel: 5
matrix:
python-version: ['3.10']
django-version: ['3.2', '4.0', '4.2']
django-version: ['3.2', '4.0', '4.2', '5.0']
include:
- django-version: 'main'
python-version: '3.10'
Expand Down
16 changes: 12 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,20 @@ jobs:
max-parallel: 5
matrix:
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']
django-version: ['3.2', '4.0', '4.2']
include:
- django-version: 'main'
django-version: ['3.2', '4.0', '4.2', '5.0']
exclude:
- python-version: '3.11'
django-version: '3.2'
- python-version: '3.12'
django-version: '3.2'
- django-version: '5.0'
python-version: '3.8'
- django-version: '5.0'
python-version: '3.9'
- django-version: 'main'
python-version: '3.10'
python-version: '3.8'
- django-version: 'main'
python-version: '3.9'

services:
postgres:
Expand Down
17 changes: 17 additions & 0 deletions django_redshift_backend/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from django.conf import settings
from django.core.exceptions import FieldDoesNotExist
from django.db.models import Index
from django.db.models.expressions import Col
from django.db.utils import NotSupportedError, ProgrammingError

from ._vendor.django40.db.backends.base.introspection import FieldInfo, TableInfo
Expand Down Expand Up @@ -58,6 +59,8 @@ class DatabaseFeatures(BasePGDatabaseFeatures):
allows_group_by_select_index = True # since django-4.2
# since django-4.2. I don't know the Redshift supports comments or not.
supports_comments = False
# since django-5.0. I don't know the Redshift supports default expression
supports_default_keyword_in_insert = False # TODO: research

# If support atomic for ddl, we should implement non-atomic migration for on rename and change type(size)
# refs django-redshift-backend #96
Expand Down Expand Up @@ -146,6 +149,20 @@ def on_conflict_suffix_sql(
):
return ""

# copy from djang 5.0 postgresql/operations.py
def prepare_join_on_clause(self, lhs_table, lhs_field, rhs_table, rhs_field):
lhs_expr = Col(lhs_table, lhs_field)
rhs_expr = Col(rhs_table, rhs_field)

# Cast is not impremented for redshift.
# Because the following code generate redundant SQL like:
# ... LEFT OUTER JOIN "tbl2" ON ("tbl1"."id" = CAST("tbl2"."parent_id" AS integer))

# if lhs_field.db_type(self.connection) != rhs_field.db_type(self.connection):
# rhs_expr = Cast(rhs_expr, lhs_field)

return lhs_expr, rhs_expr


def _get_type_default(field):
internal_type = field.get_internal_type()
Expand Down
2 changes: 1 addition & 1 deletion doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ Support versions
This product is tested with:

* Python-3.8, 3.9, 3.10, 3.11, 3.12
* Django-3.2, 4.0, 4.2
* Django-3.2, 4.0, 4.2, 5.0

License
=======
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ classifiers = [
"Framework :: Django :: 3.2",
"Framework :: Django :: 4.0",
"Framework :: Django :: 4.2",
"Framework :: Django :: 5.0",
"Intended Audience :: Developers",
"License :: OSI Approved :: Apache Software License",
"Programming Language :: Python",
Expand Down
6 changes: 5 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
[tox]
envlist =
py{38,39,310,311,312}-dj{32,40,42,main}
py{38,39,310}-dj{32,40,42}
py{38,39,310,311,312}-dj{40,42}
py{310,311,312}-dj{42,50}
lint
check
skipsdist = True
Expand All @@ -18,6 +20,7 @@ DJANGO =
3.2: dj32
4.0: dj40
4.2: dj42
5.0: dj50
main: djmain

[testenv]
Expand All @@ -32,6 +35,7 @@ deps =
dj32: Django>=3.2,<3.3
dj40: Django>=4.0,<4.1
dj42: Django>=4.2,<5.0
dj50: Django>=5.0,<5.1
djmain: https://github.com/django/django/archive/main.tar.gz
setenv =
DJANGO_SETTINGS_MODULE = settings
Expand Down

0 comments on commit b63286c

Please sign in to comment.