Skip to content
This repository was archived by the owner on Apr 29, 2025. It is now read-only.

Commit 9ee0f62

Browse files
committed
chore(utils/typeCast): use patched type
1 parent 75b5e45 commit 9ee0f62

File tree

3 files changed

+4
-7
lines changed

3 files changed

+4
-7
lines changed

src/config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ export function getConnectionOptions(): ConnectionOptions {
106106
connectTimeout: 60000,
107107
trace: false,
108108
supportBigNumbers: true,
109+
jsonStrings: true,
109110
...options,
110111
typeCast,
111112
namedPlaceholders: false, // we use our own named-placeholders patch, disable mysql2s

src/database/connection.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export class MySql {
3838
const [result] = await this.connection.execute({
3939
sql: query,
4040
values: values,
41-
typeCast: typeCastExecute as TypeCast,
41+
typeCast: typeCastExecute,
4242
});
4343
return result;
4444
}

src/utils/typeCast.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,17 @@ import type { TypeCastField, TypeCastNext } from 'mysql2/promise';
22

33
const BINARY_CHARSET = 63;
44

5-
interface Field extends TypeCastField {
6-
charset: number;
7-
}
8-
95
/**
106
* node-mysql2 v3.9.0 introduced (breaking) typecasting for execute methods.
117
*/
12-
export function typeCastExecute(field: Field, next: TypeCastNext) {
8+
export function typeCastExecute(field: TypeCastField, next: TypeCastNext) {
139
return next();
1410
}
1511

1612
/**
1713
* mysql-async compatible typecasting.
1814
*/
19-
export function typeCast(field: Field, next: TypeCastNext) {
15+
export function typeCast(field: TypeCastField, next: TypeCastNext) {
2016
switch (field.type) {
2117
case 'DATETIME':
2218
case 'DATETIME2':

0 commit comments

Comments
 (0)