From b071fd32d9c13f9997c67f993b06d3a25dcff7d7 Mon Sep 17 00:00:00 2001 From: Takayuki SHIMIZUKAWA Date: Tue, 20 Aug 2024 04:38:16 +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 9f37b84..d0092b1 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'", ]