Allow BLOB columns with utf8mb3 charset#144
Open
juan-ferrer-toribio wants to merge 1 commit intonevill:masterfrom
Open
Allow BLOB columns with utf8mb3 charset#144juan-ferrer-toribio wants to merge 1 commit intonevill:masterfrom
juan-ferrer-toribio wants to merge 1 commit intonevill:masterfrom
Conversation
|
I was running into this issue when using @rodrigogs/mysql-events. Since I don't have access to configure the MySQL server, which is likely the culprit of the issue (wrong charset encoding settings). The following error would be thrown when something changed in certain databases/tables/columns: which would be followed by a I patched @rodrigogs/zongji's diff --git a/node_modules/@rodrigogs/zongji/lib/common.js b/node_modules/@rodrigogs/zongji/lib/common.js
index 89bf7ed..1cb9c6f 100644
--- a/node_modules/@rodrigogs/zongji/lib/common.js
+++ b/node_modules/@rodrigogs/zongji/lib/common.js
@@ -440,7 +440,7 @@ exports.readMysqlValue = function(
} else {
if (column.charset !== null) {
// Javascript UTF8 always allows up to 4 bytes per character
- column.charset = column.charset === 'utf8mb4' ? 'utf8' : column.charset;
+ column.charset = column.charset.startsWith('utf8mb') ? 'utf8' : column.charset;
parser._encoding = column.charset;
}
result = parser.parseString(size);
@@ -457,7 +457,7 @@ exports.readMysqlValue = function(
// e.g. TINYTEXT, MEDIUMTEXT, LONGTEXT, TEXT data types
if (column.charset !== null) {
// Javascript UTF8 always allows up to 4 bytes per character
- column.charset = column.charset === 'utf8mb4' ? 'utf8' : column.charset;
+ column.charset = column.charset.startsWith('utf8mb') ? 'utf8' : column.charset;
result = iconv.decode(result, column.charset);
}
break;Maybe this can be of help to someone out there (I couldn't find any information about these errors and issue). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #143