From: Denis Laxalde Date: Thu, 11 Feb 2021 15:15:23 +0000 (+0100) Subject: Use no row factory in TypeInfo.fetch*() X-Git-Tag: 3.0.dev0~106^2~26 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=afd8bffbbd083174db546607b31c3d8879280b02;p=thirdparty%2Fpsycopg.git Use no row factory in TypeInfo.fetch*() TypeInfo.fetch() and TypeInfo.fetch_async() delegate results processing to TypeInfo._fetch() which only handle results as tuples. Therefore, we build the cursor with no row factory to guarantee this. Still we need to add a type hint on 'recs' variable because this cannot be inferred (this fixes the mypy error introduced in previous commits). --- diff --git a/psycopg3/psycopg3/_typeinfo.py b/psycopg3/psycopg3/_typeinfo.py index ce22aaffc..7e125d92b 100644 --- a/psycopg3/psycopg3/_typeinfo.py +++ b/psycopg3/psycopg3/_typeinfo.py @@ -69,9 +69,9 @@ class TypeInfo: if isinstance(name, Composable): name = name.as_string(conn) - cur = conn.cursor(binary=True) + cur = conn.cursor(binary=True, row_factory=None) cur.execute(cls._info_query, {"name": name}) - recs = cur.fetchall() + recs: Sequence[Sequence[Any]] = cur.fetchall() fields = [d[0] for d in cur.description or ()] return cls._fetch(name, fields, recs) @@ -88,9 +88,9 @@ class TypeInfo: if isinstance(name, Composable): name = name.as_string(conn) - cur = await conn.cursor(binary=True) + cur = await conn.cursor(binary=True, row_factory=None) await cur.execute(cls._info_query, {"name": name}) - recs = await cur.fetchall() + recs: Sequence[Sequence[Any]] = await cur.fetchall() fields = [d[0] for d in cur.description or ()] return cls._fetch(name, fields, recs)