chore(utils/typeCast): use patched type

This commit is contained in:
Linden committed 2024-06-17 23:42:12 +10:00
1 parent 75b5e45725
commit 9ee0f62d63
3 files changed
+4 -7

No files matched your search

+1
View File
@@ -106,6 +106,7 @@ export function getConnectionOptions(): ConnectionOptions {
connectTimeout: 60000,
trace: false,
supportBigNumbers: true,
jsonStrings: true,
...options,
typeCast,
namedPlaceholders: false, // we use our own named-placeholders patch, disable mysql2s
+1 -1
View File
@@ -38,7 +38,7 @@ export class MySql {
const [result] = await this.connection.execute({
sql: query,
values: values,
typeCast: typeCastExecute as TypeCast,
typeCast: typeCastExecute,
});
return result;
}
+2 -6
View File
@@ -2,21 +2,17 @@ import type { TypeCastField, TypeCastNext } from 'mysql2/promise';
const BINARY_CHARSET = 63;
interface Field extends TypeCastField {
charset: number;
}
/**
* node-mysql2 v3.9.0 introduced (breaking) typecasting for execute methods.
*/
export function typeCastExecute(field: Field, next: TypeCastNext) {
export function typeCastExecute(field: TypeCastField, next: TypeCastNext) {
return next();
}
/**
* mysql-async compatible typecasting.
*/
export function typeCast(field: Field, next: TypeCastNext) {
export function typeCast(field: TypeCastField, next: TypeCastNext) {
switch (field.type) {
case 'DATETIME':
case 'DATETIME2':