mirror of
https://github.com/psycopg/psycopg2.git
synced 2025-01-31 09:24:07 +03:00
Fixed use of the new return value of HstoreAdapter.get_oids()
This commit is contained in:
parent
5211e1474b
commit
9e00196165
|
@ -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")
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user