Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix reading json string #99

Merged
merged 1 commit into from
Oct 11, 2024
Merged
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
2 changes: 1 addition & 1 deletion asyncmy/replication/packets.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ def read_variable_length_string(self):
length = 0
bits_read = 0
while byte & 0x80 != 0:
byte = struct.pack("!B", self.read(1))
byte = struct.unpack("!B", self.read(1))[0]
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Could you add a test for that?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@long2ice I can confirm this change also worked for me on my system after getting issues with tables with JSON columns.

It's the same implementation that is done in pymysqlreplication project: https://github.com/julien-duponchelle/python-mysql-replication/blob/main/pymysqlreplication/packet.py#L256

length = length | ((byte & 0x7F) << bits_read)
bits_read = bits_read + 7
return self.read(length)
Expand Down