]> git.ipfire.org Git - thirdparty/psycopg.git/commitdiff
Use no row factory in TypeInfo.fetch*()
authorDenis Laxalde <denis.laxalde@dalibo.com>
Thu, 11 Feb 2021 15:15:23 +0000 (16:15 +0100)
committerDenis Laxalde <denis.laxalde@dalibo.com>
Thu, 11 Feb 2021 15:19:12 +0000 (16:19 +0100)
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).

psycopg3/psycopg3/_typeinfo.py

index ce22aaffc0165efb56b44a8ad4d17a1c51ffabef..7e125d92b5b61fcf0d85d009c52fabd0476efd36 100644 (file)
@@ -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)