From 3aae31df42ab8f791e0205ce467183f92a31dfeb Mon Sep 17 00:00:00 2001 From: David Burke Date: Thu, 23 Mar 2023 15:47:53 -0400 Subject: [PATCH 1/5] Add psycopg3 support Fixes #130 --- bitfield/types.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bitfield/types.py b/bitfield/types.py index d7f6d8fe..84ac6044 100644 --- a/bitfield/types.py +++ b/bitfield/types.py @@ -260,5 +260,6 @@ def get_label(self, flag): from django.db.backends.postgresql.base import Database Database.extensions.register_adapter(Bit, lambda x: Database.extensions.AsIs(int(x))) Database.extensions.register_adapter(BitHandler, lambda x: Database.extensions.AsIs(int(x))) -except ImproperlyConfigured: +# Ignore in psycopg3 where there is no Database.extensions nor any need to adapt types +except (ImproperlyConfigured, AttributeError): pass From 975fca3ad7b49837b5f824e918b478a3526918e3 Mon Sep 17 00:00:00 2001 From: David Burke Date: Thu, 6 Apr 2023 13:51:06 -0400 Subject: [PATCH 2/5] Add django 4.2 to tox tests --- tox.ini | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tox.ini b/tox.ini index 8eb37f01..d6e2f375 100644 --- a/tox.ini +++ b/tox.ini @@ -4,7 +4,7 @@ # https://docs.djangoproject.com/en/dev/faq/install/#what-python-version-can-i-use-with-django envlist = py{38,39,310}-django{32,40,41}-{sqlite,postgres}, - py{38,39,310,311}-django{41}-{sqlite,postgres}, + py{38,39,310,311}-django{41,42}-{sqlite,postgres}, [gh-actions] python = @@ -26,6 +26,8 @@ deps = django40: pytest-django>=4.5 django41: Django>=4.1,<4.2 django41: pytest-django>=4.5 + django42: Django>=4.2,<4.3 + django42: pytest-django>=4.5 setenv = sqlite: DB=sqlite postgres: DB=postgres From 26c6602efe6a408097c81cd49173052456d82b26 Mon Sep 17 00:00:00 2001 From: David Burke Date: Thu, 6 Apr 2023 13:56:03 -0400 Subject: [PATCH 3/5] Add psycopg3 to tox tests --- tox.ini | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tox.ini b/tox.ini index d6e2f375..a9be96d9 100644 --- a/tox.ini +++ b/tox.ini @@ -3,8 +3,9 @@ # Taken from: # https://docs.djangoproject.com/en/dev/faq/install/#what-python-version-can-i-use-with-django envlist = - py{38,39,310}-django{32,40,41}-{sqlite,postgres}, - py{38,39,310,311}-django{41,42}-{sqlite,postgres}, + py{38,39,310}-django{32,40,41}-{sqlite,postgres}-psycopg2, + py{38,39,310,311}-django{41,42}-{sqlite,postgres}-psycopg2, + py311-django42-postgres-psycopg3, [gh-actions] python = @@ -19,7 +20,8 @@ commands = passenv = DB deps = pytest - psycopg2-binary>=2.8 + psycopg2: psycopg2-binary>=2.8 + psycopg3: psycopg-binary>=3.1 django32: Django>=3.2,<3.3 django32: pytest-django>=4.2 django40: Django>=4.0,<4.1 From 13f10beff62da6c539e04cb2ef77a5142007996b Mon Sep 17 00:00:00 2001 From: David Burke Date: Thu, 6 Apr 2023 14:31:17 -0400 Subject: [PATCH 4/5] psycopg3 testing --- conftest.py | 2 +- tox.ini | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/conftest.py b/conftest.py index c2d8f2bb..fd29c779 100644 --- a/conftest.py +++ b/conftest.py @@ -21,7 +21,7 @@ def pytest_configure(config): if test_db == 'postgres': DATABASES['default'].update({ - 'ENGINE': 'django.db.backends.postgresql_psycopg2', + 'ENGINE': 'django.db.backends.postgresql', 'USER': 'postgres', }) elif test_db == 'mysql': diff --git a/tox.ini b/tox.ini index a9be96d9..72fe36ce 100644 --- a/tox.ini +++ b/tox.ini @@ -21,7 +21,7 @@ passenv = DB deps = pytest psycopg2: psycopg2-binary>=2.8 - psycopg3: psycopg-binary>=3.1 + psycopg3: psycopg[binary]=3.1 django32: Django>=3.2,<3.3 django32: pytest-django>=4.2 django40: Django>=4.0,<4.1 From 8867e5444aa5d841c228948fd903149e5acc161e Mon Sep 17 00:00:00 2001 From: David Burke Date: Thu, 6 Apr 2023 14:33:37 -0400 Subject: [PATCH 5/5] Typo --- tox.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tox.ini b/tox.ini index 72fe36ce..24080f56 100644 --- a/tox.ini +++ b/tox.ini @@ -21,7 +21,7 @@ passenv = DB deps = pytest psycopg2: psycopg2-binary>=2.8 - psycopg3: psycopg[binary]=3.1 + psycopg3: psycopg[binary]>=3.1 django32: Django>=3.2,<3.3 django32: pytest-django>=4.2 django40: Django>=4.0,<4.1