Skip to content

Commit 0d5c450

Browse files
Juan Ferrer Toribiovlasky
Juan Ferrer Toribio
authored andcommitted
Allow BLOB columns with utf8mb3 charset
1 parent 50d8a73 commit 0d5c450

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

lib/common.js

+11-2
Original file line numberDiff line numberDiff line change
@@ -440,8 +440,17 @@ exports.readMysqlValue = function(
440440
// e.g. TINYTEXT, MEDIUMTEXT, LONGTEXT, TEXT data types
441441
if (column.charset !== null) {
442442
// Javascript UTF8 always allows up to 4 bytes per character
443-
column.charset = column.charset === 'utf8mb4' ? 'utf8' : column.charset;
444-
result = iconv.decode(result, column.charset);
443+
switch (column.charset) {
444+
case 'utf8mb3':
445+
case 'utf8mb4':
446+
column.charset = 'utf8';
447+
break;
448+
}
449+
try {
450+
result = iconv.decode(result, column.charset);
451+
} catch (err) {
452+
console.warn(err);
453+
}
445454
}
446455
break;
447456
case MysqlTypes.JSON:

0 commit comments

Comments
 (0)