From e6ab40d9f0dbcc70be657e39866d5bafab1b7614 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Grzegorz=20=C5=9Aliwi=C5=84ski?= Date: Wed, 16 Nov 2022 21:28:22 +0100 Subject: [PATCH] Add support for Django 4.1 * Strip IDENTITY related suffixes auto fields are getting on Django 4.1. These suffixes are upsetting redshift. --- .github/workflows/test.yml | 4 +++- .gitignore | 1 + django_redshift_backend/base.py | 4 ++++ doc/index.rst | 2 +- setup.cfg | 1 + tox.ini | 1 + 6 files changed, 11 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 4837606..336cd81 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -11,10 +11,12 @@ jobs: max-parallel: 5 matrix: python-version: ['3.7', '3.8', '3.9', '3.10'] - django-version: ['3.2', '4.0'] + django-version: ['3.2', '4.0', '4.1'] exclude: - django-version: '4.0' python-version: '3.7' + - django-version: '4.1' + python-version: '3.7' include: - django-version: 'main' python-version: '3.9' diff --git a/.gitignore b/.gitignore index b5e9346..fd8a5d0 100644 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,4 @@ doc/_build/ coverage.xml **/.env examples/**/migrations/* +.idea/ \ No newline at end of file diff --git a/django_redshift_backend/base.py b/django_redshift_backend/base.py index df6cf2b..2e1ff33 100644 --- a/django_redshift_backend/base.py +++ b/django_redshift_backend/base.py @@ -1092,6 +1092,10 @@ class DatabaseWrapper(BasePGDatabaseWrapper): data_types = deepcopy(BasePGDatabaseWrapper.data_types) data_types.update(redshift_data_types) + # Clear suffixes to rid of PostgreSQLs GENERATED BY DEFAULT AS IDENTITY that upset Redshift. + # Takes effect on Django>=4.1. Older version have this attribute empty + data_types_suffix = {} + def __init__(self, *args, **kwargs): super(DatabaseWrapper, self).__init__(*args, **kwargs) diff --git a/doc/index.rst b/doc/index.rst index 24742bb..93ded67 100644 --- a/doc/index.rst +++ b/doc/index.rst @@ -44,7 +44,7 @@ Support versions This product is tested with: * Python-3.7, 3.8, 3.9, 3.10 -* Django-3.2, 4.0 +* Django-3.2, 4.0, 4.1 License ======= diff --git a/setup.cfg b/setup.cfg index c4371f0..2d5c46c 100644 --- a/setup.cfg +++ b/setup.cfg @@ -21,6 +21,7 @@ classifiers = Framework :: Django Framework :: Django :: 3.2 Framework :: Django :: 4.0 + Framework :: Django :: 4.1 Intended Audience :: Developers Environment :: Plugins Topic :: Software Development :: Libraries :: Python Modules diff --git a/tox.ini b/tox.ini index 793d3db..6f3c016 100644 --- a/tox.ini +++ b/tox.ini @@ -17,6 +17,7 @@ python = DJANGO = 3.2: dj32 4.0: dj40 + 4.1: dj41 main: djmain [testenv]