From 589f205d53f031ceb297af760f2acfc777a5bc5d Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Sat, 16 Aug 2014 13:57:46 -0400 Subject: [PATCH] - changelog for pullreq github:125 - add pg8000 version detection for the "sane multi rowcount" feature --- doc/build/changelog/changelog_09.rst | 10 ++++++++++ lib/sqlalchemy/dialects/postgresql/pg8000.py | 10 ++++++++++ 2 files changed, 20 insertions(+) diff --git a/doc/build/changelog/changelog_09.rst b/doc/build/changelog/changelog_09.rst index 0f92fb254c..b6eec2e9db 100644 --- a/doc/build/changelog/changelog_09.rst +++ b/doc/build/changelog/changelog_09.rst @@ -13,6 +13,16 @@ .. changelog:: :version: 0.9.8 + .. change:: + :tags: feature, postgresql, pg8000 + :versions: 1.0.0 + :pullreq: github:125 + + Support is added for "sane multi row count" with the pg8000 driver, + which applies mostly to when using versioning with the ORM. + The feature is version-detected based on pg8000 1.9.14 or greater + in use. Pull request courtesy Tony Locke. + .. change:: :tags: bug, engine :versions: 1.0.0 diff --git a/lib/sqlalchemy/dialects/postgresql/pg8000.py b/lib/sqlalchemy/dialects/postgresql/pg8000.py index 909b41b825..4ccc90208f 100644 --- a/lib/sqlalchemy/dialects/postgresql/pg8000.py +++ b/lib/sqlalchemy/dialects/postgresql/pg8000.py @@ -133,6 +133,16 @@ class PGDialect_pg8000(PGDialect): } ) + def initialize(self, connection): + if self.dbapi and hasattr(self.dbapi, '__version__'): + self._dbapi_version = tuple([ + int(x) for x in + self.dbapi.__version__.split(".")]) + else: + self._dbapi_version = (99, 99, 99) + self.supports_sane_multi_rowcount = self._dbapi_version >= (1, 9, 14) + super(PGDialect_pg8000, self).initialize(connection) + @classmethod def dbapi(cls): return __import__('pg8000') -- 2.47.3