Skip to content

Commit

Permalink
Fix TypeError on get_attributes when result has no columns
Browse files Browse the repository at this point in the history
  • Loading branch information
fantix authored and elprans committed Sep 13, 2017
1 parent b6fe018 commit f29de23
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
3 changes: 3 additions & 0 deletions asyncpg/protocol/prepared_stmt.pyx
Expand Up @@ -40,6 +40,9 @@ cdef class PreparedStatementState:
def _get_attributes(self):
cdef Codec codec

if not self.row_desc:
return ()

result = []
for d in self.row_desc:
name = d[0]
Expand Down
4 changes: 4 additions & 0 deletions tests/test_codecs.py
Expand Up @@ -1398,3 +1398,7 @@ async def test_enum_and_range(self):
DROP TABLE testtab;
DROP TYPE enum_t;
''')

async def test_no_result(self):
st = await self.con.prepare('rollback')
self.assertTupleEqual(st.get_attributes(), ())

0 comments on commit f29de23

Please sign in to comment.