makes finagle-mysql charsets extensible #150
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
motivation
Some people have mysql databases with different character encodings. finagle-mysql doesn't support a lot right now, but it should in the future.
implementation
This is a more complicated problem than you might think at first, because different columns can theoretically be different charsets within a single database.
todo
prepared statements
I only added support for Latin-1 in this PR, because it lets me punt on encoding prepared statements. For prepared statements, we don't need to declare anything about the charset to mysql, but we do need to encode them. Because latin-1 is compatible with utf-8, this just assumes every string in a prepared statement will use utf-8. More work will need to be done to guarantee that every string in a prepared statement is encoded properly.
other charsets
The other part of this that isn't complete is that the conversion from mysql collation number to a java.nio.charset is completely punted on, and it always returns utf-8. In the future, there should be a map from collations to charsets.
thanks
Thanks @roanta for bearing with me as I muddled through the finagle-mysql code, and providing guidance.