File tree Expand file tree Collapse file tree 3 files changed +40
-8
lines changed Expand file tree Collapse file tree 3 files changed +40
-8
lines changed Original file line number Diff line number Diff line change 2020 pg_attribute ia
2121 INNER JOIN pg_class c
2222 ON (ia.attrelid = c.oid)
23+ WHERE
24+ ia.attnum > 0 AND NOT ia.attisdropped
2325 GROUP BY
2426 c.reltype
2527 ),
Original file line number Diff line number Diff line change @@ -153,8 +153,14 @@ cdef class Codec:
153153
154154 if received_elem_typ != elem_typ:
155155 raise RuntimeError (
156- ' unexpected attribute data type: {}, expected {}'
157- .format(received_elem_typ, elem_typ))
156+ ' unexpected data type of composite type attribute {}: '
157+ ' {!r}, expected {!r}'
158+ .format(
159+ i,
160+ TYPEMAP.get(received_elem_typ, received_elem_typ),
161+ TYPEMAP.get(elem_typ, elem_typ)
162+ )
163+ )
158164
159165 elem_len = hton.unpack_int32(buf.read(4 ))
160166 if elem_len == - 1 :
Original file line number Diff line number Diff line change @@ -867,12 +867,36 @@ async def test_composites_in_arrays(self):
867867 CREATE TABLE tab (d t[]);
868868 ''' )
869869
870- await self .con .execute (
871- 'INSERT INTO tab (d) VALUES ($1)' ,
872- [('a' , 1 )])
870+ try :
871+ await self .con .execute (
872+ 'INSERT INTO tab (d) VALUES ($1)' ,
873+ [('a' , 1 )])
874+
875+ r = await self .con .fetchval ('''
876+ SELECT d FROM tab
877+ ''' )
878+
879+ self .assertEqual (r , [('a' , 1 )])
880+ finally :
881+ await self .con .execute ('''
882+ DROP TABLE tab;
883+ DROP TYPE t;
884+ ''' )
873885
874- r = await self .con .fetchval ('''
875- SELECT d FROM tab
886+ async def test_table_as_composite (self ):
887+ await self .con .execute ('''
888+ CREATE TABLE tab (a text, b int);
889+ INSERT INTO tab VALUES ('1', 1);
876890 ''' )
877891
878- self .assertEqual (r , [('a' , 1 )])
892+ try :
893+ r = await self .con .fetchrow ('''
894+ SELECT tab FROM tab
895+ ''' )
896+
897+ self .assertEqual (r , (('1' , 1 ),))
898+
899+ finally :
900+ await self .con .execute ('''
901+ DROP TABLE tab;
902+ ''' )
You can’t perform that action at this time.
0 commit comments