mirror of
https://github.com/darksaid98/oxmysql.git
synced 2026-12-04 06:28:53 +00:00
fix: Add charset to cast binary and json data correctly
This commit is contained in:
2 files changed
+16
-1
No files matched your search
@@ -191,6 +191,18 @@ index c612f66..02dbe22 100644
|
|||||||
|
|
||||||
case 'number':
|
case 'number':
|
||||||
type = Types.DOUBLE;
|
type = Types.DOUBLE;
|
||||||
|
diff --git a/node_modules/mysql2/lib/parsers/text_parser.js b/node_modules/mysql2/lib/parsers/text_parser.js
|
||||||
|
index 0af4a7a..bce66bc 100644
|
||||||
|
--- a/node_modules/mysql2/lib/parsers/text_parser.js
|
||||||
|
+++ b/node_modules/mysql2/lib/parsers/text_parser.js
|
||||||
|
@@ -85,6 +85,7 @@ function compile(fields, options, config) {
|
||||||
|
db: field.schema,
|
||||||
|
table: field.table,
|
||||||
|
name: field.name,
|
||||||
|
+ charset: field.characterSet,
|
||||||
|
string: function() {
|
||||||
|
return _this.packet.readLengthCodedString(field.encoding);
|
||||||
|
},
|
||||||
diff --git a/node_modules/mysql2/promise.d.ts b/node_modules/mysql2/promise.d.ts
|
diff --git a/node_modules/mysql2/promise.d.ts b/node_modules/mysql2/promise.d.ts
|
||||||
index 6ab3d6f..64246e8 100644
|
index 6ab3d6f..64246e8 100644
|
||||||
--- a/node_modules/mysql2/promise.d.ts
|
--- a/node_modules/mysql2/promise.d.ts
|
||||||
|
|||||||
@@ -1,9 +1,12 @@
|
|||||||
import { FieldPacket } from 'mysql2';
|
import { FieldPacket } from 'mysql2';
|
||||||
|
|
||||||
|
const BINARY_CHARSET = 63;
|
||||||
|
|
||||||
type Field = {
|
type Field = {
|
||||||
type: string;
|
type: string;
|
||||||
length: number;
|
length: number;
|
||||||
packet: FieldPacket;
|
packet: FieldPacket;
|
||||||
|
charset: number;
|
||||||
string: () => string;
|
string: () => string;
|
||||||
buffer: () => number[];
|
buffer: () => number[];
|
||||||
};
|
};
|
||||||
@@ -27,7 +30,7 @@ export const typeCast = (field: Field, next: () => void) => {
|
|||||||
case 'MEDIUM_BLOB':
|
case 'MEDIUM_BLOB':
|
||||||
case 'LONG_BLOB':
|
case 'LONG_BLOB':
|
||||||
case 'BLOB':
|
case 'BLOB':
|
||||||
if (field.packet?.charsetNr === 63) {
|
if (field.charset === BINARY_CHARSET) {
|
||||||
return [...field.buffer()];
|
return [...field.buffer()];
|
||||||
}
|
}
|
||||||
return field.string();
|
return field.string();
|
||||||
|
|||||||
Reference in new issue
Block a user