Skip to content

Conversation

@mattrobenolt
Copy link
Member

@mattrobenolt mattrobenolt commented Apr 25, 2024

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

@mattrobenolt mattrobenolt requested a review from ayrton April 25, 2024 01:24
@mattrobenolt mattrobenolt force-pushed the fix-cast branch 2 times, most recently from d014905 to ae92750 Compare April 25, 2024 02:07
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
@mattrobenolt mattrobenolt force-pushed the fix-cast branch 2 times, most recently from 8b95a38 to b5c7ed8 Compare April 25, 2024 20:20
fetch
}

function uint8ArrayFromHex(text: string): Uint8Array {
Copy link
Member Author

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 ayrton enabled auto-merge (squash) April 25, 2024 21:44
@mattrobenolt
Copy link
Member Author

@ayrton I can't approve your changes since I created the PR, but everything I brought up was addressed, looks good to me.

@ayrton ayrton merged commit ac5bdc4 into main Apr 25, 2024
@ayrton ayrton deleted the fix-cast branch April 25, 2024 21:58
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.

UUIDs Get Returned Incorrectly

2 participants