Skip to content

Commit c521c95

Browse files
author
James William Pye
committed
Fix composite typio.
Arrays of composite types work as well. :)
1 parent 31154af commit c521c95

1 file changed

Lines changed: 7 additions & 10 deletions

File tree

postgresql/protocol/typio.py

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -398,12 +398,12 @@ def transform_record(obj_xf, raw_columns, io):
398398
if x is None:
399399
yield None
400400
else:
401-
yield obj_xf[io][i](x)
401+
yield obj_xf[i][io](x)
402402

403403
def composite_typio(
404404
cio : "sequence (pack,unpack) tuples corresponding to the",
405+
typids : "sequence of type Oids; index must correspond to the composite's",
405406
attmap : "mapping of column name to index number",
406-
typids : "sequence of type Oids; index must correspond to the composite's"
407407
):
408408
"""
409409
create the typio pair for the composite type metadata passed in.
@@ -625,15 +625,12 @@ def resolve(
625625
for x in self.lookup_composite_type_info(typrelid):
626626
attmap[x[1]] = i
627627
typids.append(x[0])
628-
cio.append(self.resolve(
629-
x[0],
630-
list(from_resolution_of) + [typid]
631-
))
628+
pack, unpack = self.resolve(
629+
x[0], list(from_resolution_of) + [typid]
630+
)
631+
cio.append((pack or self.encode, unpack or self.decode))
632632
i += 1
633-
634-
self._cache[typid] = typio = composite_typio(
635-
cio, typids, attmap
636-
)
633+
self._cache[typid] = typio = composite_typio(cio, typids, attmap)
637634
elif ae_typid is not None:
638635
# Array Type
639636
te = self.resolve(

0 commit comments

Comments
 (0)