The most likely cause is fetching info and the object is not found.
Suggest that that's what happened instead of throwing an AttributeError
or anything else random.
the composite into a Python object.
"""
+ # A friendly error warning instead of an AttributeError in case fetch()
+ # failed and it wasn't noticed.
+ if not info:
+ raise TypeError(
+ "no info passed. Is the requested composite available?"
+ )
+
# Register arrays and type info
info.register(context)
:param context: The context where to register the adapters. If `!None`,
register it globally.
"""
+ # A friendly error warning instead of an AttributeError in case fetch()
+ # failed and it wasn't noticed.
+ if not info:
+ raise TypeError("no info passed. Is the 'hstore' extension loaded?")
# Register arrays and type info
info.register(context)
Register loaders so that loading data of this type will result in a `Range`
with bounds parsed as the right subtype.
"""
+ # A friendly error warning instead of an AttributeError in case fetch()
+ # failed and it wasn't noticed.
+ if not info:
+ raise TypeError("no info passed. Is the requested range available?")
# Register arrays and type info
info.register(context)
# but the loader is registered
cur = conn.execute("select '(foo,42,3.14)'::testcomp")
assert cur.fetchone()[0] == ("foo", 42, 3.14, 3.14)
+
+
+def test_no_info_error(conn):
+ with pytest.raises(TypeError, match="composite"):
+ register_composite(None, conn)
register_hstore(TypeInfo.fetch(conn, "hstore"), conn)
samp1 = conn.execute("select %s", (samp,)).fetchone()[0]
assert samp1 == samp
+
+
+def test_no_info_error(conn):
+ with pytest.raises(TypeError, match="hstore.*extension"):
+ register_hstore(None, conn)
expected = "[2010-01-01 00:00:00-05:00, 2011-01-01 00:00:00-05:00)"
result = str(r)
assert result == expected
+
+
+def test_no_info_error(conn):
+ with pytest.raises(TypeError, match="range"):
+ register_range(None, conn)