Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion asyncpg/protocol/protocol.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -801,7 +801,10 @@ cdef class BaseProtocol(CoreProtocol):
waiter.set_result(self.result)

cdef _on_result__simple_query(self, object waiter):
waiter.set_result(self.result_status_msg.decode(self.encoding))
if self.result_status_msg is not None:
waiter.set_result(self.result_status_msg.decode(self.encoding))
else:
waiter.set_result(None)

cdef _on_result__copy_out(self, object waiter):
cdef bint copy_done = self.state == PROTOCOL_COPY_OUT_DONE
Expand Down
13 changes: 13 additions & 0 deletions tests/test_execute.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,19 @@ async def test_execute_script_check_transactionality(self):
SELECT * FROM mytab
''')

async def test_execute_empty_script(self):
# Test executing a script with only comments (issue #1259)
result = await self.con.execute('-- hello')
self.assertIsNone(result)

# Test executing a script with only whitespace
result = await self.con.execute(' ')
self.assertIsNone(result)

# Test executing an empty script
result = await self.con.execute('')
self.assertIsNone(result)

async def test_execute_exceptions_1(self):
with self.assertRaisesRegex(asyncpg.PostgresError,
'relation "__dne__" does not exist'):
Expand Down