From 22cd98ca6d3e01227c6578ea5573c3fe8d5d14e2 Mon Sep 17 00:00:00 2001 From: Takayuki SHIMIZUKAWA Date: Sun, 28 Jul 2024 01:29:09 +0000 Subject: [PATCH] Add Django-5.0 support #143; fix errors --- .../_vendor/django40/db/backends/base/base.py | 4 ++++ django_redshift_backend/base.py | 4 +++- pyproject.toml | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/django_redshift_backend/_vendor/django40/db/backends/base/base.py b/django_redshift_backend/_vendor/django40/db/backends/base/base.py index 56cf081..287ab0c 100644 --- a/django_redshift_backend/_vendor/django40/db/backends/base/base.py +++ b/django_redshift_backend/_vendor/django40/db/backends/base/base.py @@ -5,6 +5,7 @@ import warnings from collections import deque from contextlib import contextmanager +from datetime import timezone as pytimezone try: import zoneinfo @@ -23,6 +24,9 @@ from django.utils.asyncio import async_unsafe from django.utils.functional import cached_property +# django.utils.timezone.utc has been removed in django 5.0 +timezone.utc = pytimezone.utc + NO_DB_ALIAS = "__no_db__" diff --git a/django_redshift_backend/base.py b/django_redshift_backend/base.py index cece00a..193cf85 100644 --- a/django_redshift_backend/base.py +++ b/django_redshift_backend/base.py @@ -60,7 +60,9 @@ class DatabaseFeatures(BasePGDatabaseFeatures): # 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 + supports_default_keyword_in_insert = True # TODO: Add UnitTest https://docs.djangoproject.com/en/5.0/releases/5.0/#database-computed-default-values + supports_default_keyword_in_bulk_insert = True # TODO: Add UnitTest https://docs.djangoproject.com/en/5.0/releases/5.0/#database-computed-default-values + supports_nulls_distinct_unique_constraints = False # TODO: Add UnitTest https://docs.djangoproject.com/en/5.0/ref/models/constraints/#nulls-distinct # If support atomic for ddl, we should implement non-atomic migration for on rename and change type(size) # refs django-redshift-backend #96 diff --git a/pyproject.toml b/pyproject.toml index 10b1b99..14ece1c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -36,7 +36,7 @@ classifiers = [ "Topic :: Software Development :: Libraries :: Python Modules", ] dependencies = [ - "django<5", + "django<5.1", "backports.zoneinfo;python_version<'3.9'", ]