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

psycopg3 compatibility #107

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
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
30 changes: 9 additions & 21 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,33 +12,20 @@ jobs:
strategy:
fail-fast: false
matrix:
python: ['3.7', '3.8', '3.9']
python: ['3.8', '3.9', '3.10']
# Time to switch to pytest or nose2?
# nosetests is broken on 3.10
# AttributeError: module 'collections' has no attribute 'Callable'
# https://github.com/nose-devs/nose/issues/1099
django:
- 'Django~=3.2.0'
- 'Django~=4.0.0'
- 'Django~=4.1.0'
- 'Django~=4.2.0'
- 'Django~=3.2.0'
- 'Django~=4.0.0'
- 'Django~=4.1.0'
- 'Django~=4.2.0'
psycopg:
- 'psycopg2>2.9'
- 'psycopg>=3.1.8'
experimental: [false]
# include:
# - python: '3.9'
# django: 'https://github.com/django/django/archive/refs/heads/main.zip#egg=Django'
# experimental: true
# NOTE this job will appear to pass even when it fails because of
# `continue-on-error: true`. Github Actions apparently does not
# have this feature, similar to Travis' allow-failure, yet.
# https://github.com/actions/toolkit/issues/399
exclude:
- python: '3.7'
django: 'Django~=4.0.0'
- python: '3.7'
django: 'Django~=4.1.0'
- python: '3.7'
django: 'Django~=4.2.0'

services:
postgres:
image: postgres:latest
Expand All @@ -65,6 +52,7 @@ jobs:
pip install -r requirements/requirements.txt
pip install -r requirements/requirements-testing.txt
pip install "${{ matrix.django }}"
pip uninstall psycopg psycopg2 && pip install "${{ matrix.psycopg }}"
pip freeze
- name: Run tests
env:
Expand Down
4 changes: 4 additions & 0 deletions ambition_utils/docs/release_notes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
Release Notes
=============

3.2.0
------
* Add support for psycopg (psycopg3). Still supports psycopg2.

3.1.11
------
* migration adjustment
Expand Down
2 changes: 1 addition & 1 deletion ambition_utils/sql.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def run(self):
self._raw_results = list(cursor.fetchall())
self._raw_columns = [col[0] for col in cursor.description]
except ProgrammingError as e:
if str(e) == 'no results to fetch':
if str(e) == 'no results to fetch' or str(e) == "the last operation didn't produce a result":
self._raw_results = []
self._raw_columns = []
else: # pragma: no cover No expected to hit this, but raise just in case
Expand Down
2 changes: 1 addition & 1 deletion ambition_utils/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '3.1.11'
__version__ = '3.2.0'
4 changes: 4 additions & 0 deletions manage.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
#!/usr/bin/env python
import sys

# These lines allow nose tests to work in Python 3.10
import collections.abc
collections.Callable = collections.abc.Callable

# Show warnings about django deprecations - uncomment for version upgrade testing
import warnings
from django.utils.deprecation import RemovedInNextVersionWarning
Expand Down