Skip to content

Commit f29de23

Browse files
fantixelprans
authored andcommitted
Fix TypeError on get_attributes when result has no columns
1 parent b6fe018 commit f29de23

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

asyncpg/protocol/prepared_stmt.pyx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ cdef class PreparedStatementState:
4040
def _get_attributes(self):
4141
cdef Codec codec
4242

43+
if not self.row_desc:
44+
return ()
45+
4346
result = []
4447
for d in self.row_desc:
4548
name = d[0]

tests/test_codecs.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1398,3 +1398,7 @@ async def test_enum_and_range(self):
13981398
DROP TABLE testtab;
13991399
DROP TYPE enum_t;
14001400
''')
1401+
1402+
async def test_no_result(self):
1403+
st = await self.con.prepare('rollback')
1404+
self.assertTupleEqual(st.get_attributes(), ())

0 commit comments

Comments
 (0)