From 552e0a8e560bff6df2c28f6216c68514c0d7133c Mon Sep 17 00:00:00 2001 From: Nikita Grishko Date: Wed, 3 Jan 2018 21:13:35 +0100 Subject: [PATCH] Fix SQLAlchemy 1.2.0 compatibility (#411) (#412) --- aiopg/sa/result.py | 7 ++++++- requirements.txt | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/aiopg/sa/result.py b/aiopg/sa/result.py index 1e47c4cb..f3106d14 100644 --- a/aiopg/sa/result.py +++ b/aiopg/sa/result.py @@ -100,7 +100,12 @@ def __init__(self, result_proxy, metadata): self._keymap = keymap = {} self.keys = [] dialect = result_proxy.dialect - typemap = dialect.dbapi_type_map + + # `dbapi_type_map` property removed in SQLAlchemy 1.2+. + # Usage of `getattr` only needed for backward compatibility with + # older versions of SQLAlchemy. + typemap = getattr(dialect, 'dbapi_type_map', {}) + assert dialect.case_sensitive, \ "Doesn't support case insensitive database connection" diff --git a/requirements.txt b/requirements.txt index 2e89ed2b..940acdb5 100644 --- a/requirements.txt +++ b/requirements.txt @@ -11,5 +11,5 @@ pytest-cov==2.5.1 pytest-sugar==0.9.0 pytest-timeout==1.2.1 sphinxcontrib-asyncio==0.2.0 -sqlalchemy==1.1.15 +sqlalchemy==1.2.0 psycopg2==2.6.2