-
Notifications
You must be signed in to change notification settings - Fork 36
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 cast logic #174
Fix cast logic #174
Conversation
d014905
to
ae92750
Compare
There's a lot to unpack here, but the tl;dr is to refer to the charset ultimately to determine if the data is UTF8, if it is, we can decode it to a UTF8 string. This fixes behavior around CHAR/TEXT fields with a binary collation, being surfaces as BINARY/BLOB types by MySQL. For all intents and purposes, BLOB/BINARY/CHAR/TEXT are all effectively identical and interchangeable, the only differentiator is their charset. Either they are a UTF-8 charset, or a binary charset or some other charset. Fixes #169
8b95a38
to
b5c7ed8
Compare
__tests__/index.test.ts
Outdated
@@ -13,6 +16,13 @@ const config = { | |||
fetch | |||
} | |||
|
|||
function uint8ArrayFromHex(text: string): Uint8Array { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This helper was nice becuase it makes it easier to copy/paste the hex output from mysql CLI for it's rendering of binary data. Figured I'd like to have a source of truth to copy/paste from rather than hand writing each byte in a Uint8Array.
@ayrton I can't approve your changes since I created the PR, but everything I brought up was addressed, looks good to me. |
There's a lot to unpack here, but the tl;dr is to refer to the charset ultimately to determine if the data is binary, or non-binary which is always UTF-8.
This fixes behavior around CHAR/TEXT fields with a binary collation, being surfaces as BINARY/BLOB types by MySQL.
For all intents and purposes, BLOB/BINARY/CHAR/TEXT are all effectively identical and interchangeable, the only differentiator is their charset. Either they are a binary charset, or they are encoded as UTF-8.
This behavior seems to differ slightly from vanilla MySQL and is specific to potentially a bug in Vitess, but this default is much safer for future proofing if we fix things there.
Fixes #169 #171