-
Notifications
You must be signed in to change notification settings - Fork 72
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
Client now accepts :encoding
option.
#64
Conversation
07115bc
to
80c31b8
Compare
Down in the C library, UTF8 is passed as the default encoding during the authentication phase of connection. Even though Along those lines, it would be a little more efficient to change the C API to allow the client encoding to be passed in to |
That's great feedback, thanks @brianmario ! ❤️ I'll add a commit with the proposed changes to pass encoding through to If we'd like to avoid breaking changes to the C API, sounds like we can at the very least avoid calling |
If you're referring to the Ruby client then I personally think so, yeah. I'm not sure if we should change the default down in the C library as well. Probably? But that would be a breaking change as well. |
Yeah I was referring to the C library, but figured that would be a breaking change 😅 So maybe not doable if we wanted to avoid that. |
I think I'm inclined to wear the breakage here... it seems like something we're going to have to address at some point, so the sooner the better. And making it configurable at connect time should allow a smooth user-level transition (C API change notwithstanding): we can start defaulting to the more modern (Without investigation, changing the initial default rather than using a post-connect |
ed7038d
to
960aa62
Compare
I wonder if we should restrict the accepted encodings to only ASCII-compatible (at least from the Ruby client). It feels dangerous to expose an API which could have a broken |
@jhawthorn sorry missed your comment earlier!
The implementation right now does restrict encodings to ASCII-compatible only: I haven't made any changes to escape -- it maintains the string's original encoding though, so I was wondering if we wanted to change it to encode in the expected connection encoding (assuming the connection encoding is ASCII-compatible too). What do you think? |
c98af25
to
1c822e6
Compare
In trilogy-libraries/trilogy#64 we're adding Trilogy as an additional mysql client for Rails. This change adds a new build for it.
One suggestion (and a rebase needed). Otherwise looks good to me 🙌 |
When :encoding is supplied to the client, the charset for the MySQL server is set accordingly. Additionally, we ensure that the client sends query strings in the encoding the connection expects. Co-authored-by: Jean Boussier <jean.boussier@shopify.com>
Rather than performing `SET NAMES` in the client constructor on the Ruby side, we can set the charset during the authentication phase. To do so, we must find the mysql-to-charset mapping for the requested encoding, and pass it through to the C API.
1c822e6
to
b8c0d51
Compare
Thanks again! |
When
:encoding
is supplied to the client, the charset for the MySQL server is set accordingly. Additionally, we ensure that the client sends query strings in the encoding the connection expects.This will align Trilogy's encoding behaviour with Mysql2's.
Looking for Feedback
utf8mb4
if none is passed to the client, or not set anything?rb_trilogy_escape
as well, as long as the connection encoding is ASCII-compatible?