Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Django 4.1 #111

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

memo: django 4.1 supports python 3.8 or later
https://docs.djangoproject.com/en/4.1/releases/4.1/

include:
- django-version: 'main'
python-version: '3.9'
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ doc/_build/
coverage.xml
**/.env
examples/**/migrations/*
.idea/
17 changes: 17 additions & 0 deletions django_redshift_backend/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1083,15 +1083,32 @@ def get_table_list(self, cursor):
""")
return [TableInfo(*row) for row in cursor.fetchall() if row[0] not in self.ignored_tables]

def get_field_type(self, data_type, description):
# instead of calling a parent method, doing directly what grapndparent class does.
field_type = self.data_types_reverse[data_type]
if description.default and "nextval" in description.default:
if field_type == "IntegerField":
return "AutoField"
elif field_type == "BigIntegerField":
return "BigAutoField"
elif field_type == "SmallIntegerField":
return "SmallAutoField"
return field_type


class DatabaseWrapper(BasePGDatabaseWrapper):
vendor = 'redshift'
display_name = "AWS Redshift"

SchemaEditorClass = DatabaseSchemaEditor

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)

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.7, 3.8, 3.9, 3.10
* Django-3.2, 4.0
* Django-3.2, 4.0, 4.1

License
=======
Expand Down
1 change: 1 addition & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[tox]
envlist =
py37-dj32
py{38,39,310}-dj{32,40,main}
py{38,39,310}-dj{32,40,41,main}
flake8
check
skipsdist = True
Expand All @@ -17,6 +17,7 @@ python =
DJANGO =
3.2: dj32
4.0: dj40
4.1: dj41
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We also need dj41 in envlist (line 2) and deps (line 32)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

main: djmain

[testenv]
Expand All @@ -28,6 +29,7 @@ deps =
mock>=2.0
dj32: Django>=3.2,<3.3
dj40: Django>=4.0,<4.1
dj41: Django>=4.1,<4.2
djmain: https://github.com/django/django/archive/main.tar.gz
setenv =
DJANGO_SETTINGS_MODULE = settings
Expand Down