Fixed use of the new return value of HstoreAdapter.get_oids()

This commit is contained in:
Daniele Varrazzo 2011-02-25 01:37:02 +00:00
parent 5211e1474b
commit 9e00196165
2 changed files with 2 additions and 4 deletions

View File

@ -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")

View File

@ -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)