From: Daniele Varrazzo Date: Tue, 13 Jul 2021 01:55:05 +0000 (+0200) Subject: Corrections to the types module docs X-Git-Tag: 3.0.dev1~16 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=c9e1f3ec0b66eae1c4244bce8cb7c0142a9572ba;p=thirdparty%2Fpsycopg.git Corrections to the types module docs --- diff --git a/docs/api/types.rst b/docs/api/types.rst index bf63d09e6..eaf6c8a82 100644 --- a/docs/api/types.rst +++ b/docs/api/types.rst @@ -20,11 +20,11 @@ type, such as its name, oid and array oid. The class can be used to query a database for custom data types: this allows for instance to load automatically arrays of a custom type, once a loader for the base type has been registered. -The `!TypeInfo` object doesn't instruct Psycopg to convert a PostgreSQL -type into a Python type: this is the role of a `Loader`. However it can extend -the behaviour of the adapters: if you create a loader for `!MyType`, using -`TypeInfo` you will be able to manage seamlessly arrays of `!MyType` or ranges -and composite types using it as a subtypes. +The `!TypeInfo` object doesn't instruct Psycopg to convert a PostgreSQL type +into a Python type: this is the role of a `~psycopg.abc.Loader`. However it +can extend the behaviour of the adapters: if you create a loader for +`!MyType`, using `TypeInfo` you will be able to manage seamlessly arrays of +`!MyType` or ranges and composite types using it as a subtype. .. seealso:: :ref:`adaptation` describes about how to convert from Python types to PostgreSQL types and back. @@ -44,7 +44,7 @@ and composite types using it as a subtypes. def load(self, data): # parse the data and return a MyType instance - MyTypeLoader.register(conn) + conn.adapters.register_loader("mytype", MyTypeLoader) for record in conn.execute("select mytypearray from mytable"): # records will return lists of MyType instances diff --git a/psycopg/psycopg/_typeinfo.py b/psycopg/psycopg/_typeinfo.py index 1d9f5c89a..2a38723cd 100644 --- a/psycopg/psycopg/_typeinfo.py +++ b/psycopg/psycopg/_typeinfo.py @@ -63,6 +63,7 @@ class TypeInfo: :param conn: the connection to query :param name: the name of the type to query. It can include a schema name. + :type name: `!str` or `~psycopg.sql.Identifier` :return: a `!TypeInfo` object populated with the type information, `!None` if not found. """