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

read mysql text column (utf8 charset) as string column #660

Merged
merged 1 commit into from
Jul 9, 2024

Conversation

Cabbagec
Copy link
Contributor

@Cabbagec Cabbagec commented Jul 6, 2024

Encountered with the same problem as #464 and #510 , where text type columns in mysql are interpreted as binary ones naively, which is technically ok, according to the mysql doc that the text types are basically just blob types, except for additional charset requirements.

But it's quite an inconvenient for users must do decoding themselves on the final result. So I made and tested this patch in our environment as an easy workaround. Note that we only use UTF8 charset for text fields in our databases, so this patch only works for UTF8 text fields. For other encodings like GBK, SHIFT_JIS, BIG5, etc., it won't work, additional decoding is still needed.

If anyone interested, I recommend checking out this crate encoding_rs, then doing decoding steps according to the mysql field charset info.

@wangxiaoying
Copy link
Contributor

Thanks @Cabbagec for the PR and testing!

@wangxiaoying wangxiaoying merged commit 8dee3a6 into sfu-db:main Jul 9, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants