Skip to content

Commit 9a55db5

Browse files
committed
Extract _build_parse_message()
1 parent 0d5cdcd commit 9a55db5

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

asyncpg/protocol/coreproto.pxd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ cdef class CoreProtocol:
144144

145145
cdef _ensure_connected(self)
146146

147+
cdef WriteBuffer _build_parse_message(self, str stmt_name, query)
147148
cdef WriteBuffer _build_bind_message(self, str portal_name,
148149
str stmt_name,
149150
WriteBuffer bind_data)

asyncpg/protocol/coreproto.pyx

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -684,6 +684,17 @@ cdef class CoreProtocol:
684684
if self.con_status != CONNECTION_OK:
685685
raise apg_exc.InternalClientError('not connected')
686686

687+
cdef WriteBuffer _build_parse_message(self, str stmt_name, query):
688+
cdef WriteBuffer buf
689+
690+
buf = WriteBuffer.new_message(b'P')
691+
buf.write_str(stmt_name, self.encoding)
692+
buf.write_str(query, self.encoding)
693+
buf.write_int16(0)
694+
695+
buf.end_message()
696+
return buf
697+
687698
cdef WriteBuffer _build_bind_message(self, str portal_name,
688699
str stmt_name,
689700
WriteBuffer bind_data):
@@ -762,11 +773,7 @@ cdef class CoreProtocol:
762773

763774
packet = WriteBuffer.new()
764775

765-
buf = WriteBuffer.new_message(b'P')
766-
buf.write_str(stmt_name, self.encoding)
767-
buf.write_str(query, self.encoding)
768-
buf.write_int16(0)
769-
buf.end_message()
776+
buf = self._build_parse_message(stmt_name, query)
770777
packet.write_buffer(buf)
771778

772779
buf = WriteBuffer.new_message(b'D')

0 commit comments

Comments
 (0)