From 9e00196165a60e9cb93ae391cef0d43a9207ae18 Mon Sep 17 00:00:00 2001 From: Daniele Varrazzo Date: Fri, 25 Feb 2011 01:37:02 +0000 Subject: [PATCH] Fixed use of the new return value of HstoreAdapter.get_oids() --- lib/extras.py | 4 +--- tests/types_extras.py | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/extras.py b/lib/extras.py index 1e8d528d..21c5849c 100644 --- a/lib/extras.py +++ b/lib/extras.py @@ -664,8 +664,6 @@ class HstoreAdapter(object): @classmethod def get_oids(self, conn_or_curs): """Return the lists of OID of the hstore and hstore[] types. - - Return None if hstore is not available. """ if hasattr(conn_or_curs, 'execute'): conn = conn_or_curs.connection @@ -734,7 +732,7 @@ def register_hstore(conn_or_curs, globally=False, unicode=False, oid=None): """ if oid is None: oid = HstoreAdapter.get_oids(conn_or_curs) - if oid is None: + if oid is None or not oid[0]: raise psycopg2.ProgrammingError( "hstore type not found in the database. " "please install it from your 'contrib/hstore.sql' file") diff --git a/tests/types_extras.py b/tests/types_extras.py index 5c558cfc..d6b5726f 100755 --- a/tests/types_extras.py +++ b/tests/types_extras.py @@ -120,7 +120,7 @@ def skip_if_no_hstore(f): def skip_if_no_hstore_(self): from psycopg2.extras import HstoreAdapter oids = HstoreAdapter.get_oids(self.conn) - if oids is None: + if oids is None or not oids[0]: return self.skipTest("hstore not available in test database") return f(self)