Update Fix

This commit is contained in:
2026-03-15 12:30:40 +01:00
parent 311ba5e7f3
commit 50be8e25f3
176 changed files with 4075 additions and 3013 deletions

View File

@@ -1,6 +1,3 @@
/**
* sqlstring types are based on https://www.npmjs.com/package/@types/sqlstring, version 2.3.2
*/
import { Pool as BasePool, PoolOptions } from './lib/Pool.js';
import {
Connection as BaseConnection,
@@ -23,6 +20,13 @@ import {
PrepareStatementInfo,
} from './lib/protocol/sequences/Prepare.js';
import { Server } from './lib/Server.js';
import {
escape as SqlStringEscape,
escapeId as SqlStringEscapeId,
format as SqlStringFormat,
raw as SqlStringRaw,
} from 'sql-escaper';
export type { Raw, SqlValue, Timezone } from 'sql-escaper';
export {
ConnectionOptions,
@@ -57,26 +61,10 @@ export function createPool(config: PoolOptions): BasePool;
export function createPoolCluster(config?: PoolClusterOptions): PoolCluster;
type TimeZone = 'local' | 'Z' | (string & NonNullable<unknown>);
export function escape(
value: any,
stringifyObjects?: boolean,
timeZone?: TimeZone
): string;
export function escapeId(value: any, forbidQualified?: boolean): string;
export function format(sql: string): string;
export function format(
sql: string,
values: any | any[],
stringifyObjects?: boolean,
timeZone?: TimeZone
): string;
export function raw(sql: string): {
toSqlString: () => string;
};
export const escape: typeof SqlStringEscape;
export const escapeId: typeof SqlStringEscapeId;
export const format: typeof SqlStringFormat;
export const raw: typeof SqlStringRaw;
export interface ConnectionConfig extends ConnectionOptions {
mergeFlags(defaultFlags: string[], userFlags: string[] | string): number;

View File

@@ -5,6 +5,7 @@
import { EventEmitter } from 'events';
import { Readable } from 'stream';
import { Timezone } from 'sql-escaper';
import { Query, QueryError } from './protocol/sequences/Query.js';
import { Prepare, PrepareStatementInfo } from './protocol/sequences/Prepare.js';
import {
@@ -150,7 +151,7 @@ export interface ConnectionOptions {
/**
* The timezone used to store local dates. (Default: 'local')
*/
timezone?: string | 'local';
timezone?: Timezone;
/**
* The milliseconds before a timeout occurs during the initial connection to the MySQL server. (Default: 10 seconds)
@@ -393,6 +394,8 @@ declare class Connection extends QueryableBase(ExecutableBase(EventEmitter)) {
end(callback?: (err: QueryError | null) => void): void;
end(options: any, callback?: (err: QueryError | null) => void): void;
[Symbol.dispose](): void;
destroy(): void;
pause(): void;

View File

@@ -53,6 +53,8 @@ declare class Pool extends QueryableBase(ExecutableBase(EventEmitter)) {
callback?: (err: NodeJS.ErrnoException | null, ...args: any[]) => any
): void;
[Symbol.dispose](): void;
on(event: string, listener: (...args: any[]) => void): this;
on(event: 'connection', listener: (connection: PoolConnection) => any): this;
on(event: 'acquire', listener: (connection: PoolConnection) => any): this;

View File

@@ -56,6 +56,8 @@ declare class PoolCluster extends EventEmitter {
end(callback?: (err: NodeJS.ErrnoException | null) => void): void;
[Symbol.dispose](): void;
getConnection(
callback: (
err: NodeJS.ErrnoException | null,

View File

@@ -4,6 +4,7 @@ import { Pool as PromisePool } from '../../../promise.js';
declare class PoolConnection extends Connection {
connection: Connection;
release(): void;
[Symbol.dispose](): void;
promise(promiseImpl?: PromiseConstructor): PromisePool;
}

View File

@@ -3,6 +3,7 @@ import {
Query,
QueryError,
QueryOptions,
ExecuteValues,
QueryableConstructor,
} from './Query.js';
@@ -18,7 +19,7 @@ export declare function ExecutableBase<T extends QueryableConstructor>(
): Query;
execute<T extends QueryResult>(
sql: string,
values: any,
values: ExecuteValues,
callback?:
| ((err: QueryError | null, result: T, fields: FieldPacket[]) => any)
| undefined
@@ -26,12 +27,12 @@ export declare function ExecutableBase<T extends QueryableConstructor>(
execute<T extends QueryResult>(
options: QueryOptions,
callback?:
| ((err: QueryError | null, result: T, fields?: FieldPacket[]) => any)
| ((err: QueryError | null, result: T, fields: FieldPacket[]) => any)
| undefined
): Query;
execute<T extends QueryResult>(
options: QueryOptions,
values: any,
values: ExecuteValues,
callback?:
| ((err: QueryError | null, result: T, fields: FieldPacket[]) => any)
| undefined

View File

@@ -1,8 +1,37 @@
import { Sequence } from './Sequence.js';
import { OkPacket, RowDataPacket, FieldPacket } from '../packets/index.js';
import { Readable } from 'stream';
import { Raw, Timezone } from 'sql-escaper';
import { TypeCast } from '../../parsers/typeCast.js';
export type ExecuteValues =
| string
| number
| bigint
| boolean
| Date
| null
| Blob
| Buffer
| Uint8Array
| ExecuteValues[]
| { [key: string]: ExecuteValues };
export type QueryValues =
| string
| number
| bigint
| boolean
| Date
| null
| undefined
| Blob
| Buffer
| Uint8Array
| Raw
| ({} | null | undefined)[]
| { [key: string]: QueryValues };
export interface QueryOptions {
/**
* The SQL for the query
@@ -12,7 +41,7 @@ export interface QueryOptions {
/**
* The values for the query
*/
values?: any | any[] | { [param: string]: any };
values?: QueryValues;
/**
* This overrides the namedPlaceholders option set at the connection level.
@@ -83,6 +112,35 @@ export interface QueryOptions {
* By specifying a function that returns a readable stream, an arbitrary stream can be sent when sending a local fs file.
*/
infileStreamFactory?: (path: string) => Readable;
/**
* When dealing with big numbers (BIGINT and DECIMAL columns) in the database, you should enable this option
* (Default: false)
*/
supportBigNumbers?: boolean;
/**
* Enabling both supportBigNumbers and bigNumberStrings forces big numbers (BIGINT and DECIMAL columns) to be
* always returned as JavaScript String objects (Default: false). Enabling supportBigNumbers but leaving
* bigNumberStrings disabled will return big numbers as String objects only when they cannot be accurately
* represented with JavaScript Number objects (which happens when they exceed the [-2^53, +2^53] range),
* otherwise they will be returned as Number objects.
* This option is ignored if supportBigNumbers is disabled.
*/
bigNumberStrings?: boolean;
/**
* Force date types (TIMESTAMP, DATETIME, DATE) to be returned as strings rather then inflated into JavaScript Date
* objects. Can be true/false or an array of type names to keep as strings.
*
* (Default: false)
*/
dateStrings?: boolean | Array<'TIMESTAMP' | 'DATETIME' | 'DATE'>;
/**
* The timezone used to store local dates. (Default: 'local')
*/
timezone?: Timezone;
}
export interface StreamOptions {

View File

@@ -3,6 +3,7 @@ import {
Query,
QueryError,
QueryOptions,
QueryValues,
QueryableConstructor,
} from './Query.js';
@@ -18,7 +19,7 @@ export declare function QueryableBase<T extends QueryableConstructor>(
): Query;
query<T extends QueryResult>(
sql: string,
values: any,
values: QueryValues,
callback?:
| ((err: QueryError | null, result: T, fields: FieldPacket[]) => any)
| undefined
@@ -26,12 +27,12 @@ export declare function QueryableBase<T extends QueryableConstructor>(
query<T extends QueryResult>(
options: QueryOptions,
callback?:
| ((err: QueryError | null, result: T, fields?: FieldPacket[]) => any)
| ((err: QueryError | null, result: T, fields: FieldPacket[]) => any)
| undefined
): Query;
query<T extends QueryResult>(
options: QueryOptions,
values: any,
values: QueryValues,
callback?:
| ((err: QueryError | null, result: T, fields: FieldPacket[]) => any)
| undefined

View File

@@ -1,21 +1,17 @@
import { FieldPacket, QueryResult } from '../../packets/index.js';
import { QueryOptions, QueryableConstructor } from '../Query.js';
import { QueryOptions, QueryableConstructor, ExecuteValues } from '../Query.js';
export declare function ExecutableBase<T extends QueryableConstructor>(
Base?: T
): {
new (...args: any[]): {
execute<T extends QueryResult>(sql: string): Promise<[T, FieldPacket[]]>;
execute<T extends QueryResult>(
sql: string,
values: any
): Promise<[T, FieldPacket[]]>;
execute<T extends QueryResult>(
options: QueryOptions
values?: ExecuteValues
): Promise<[T, FieldPacket[]]>;
execute<T extends QueryResult>(
options: QueryOptions,
values: any
values?: ExecuteValues
): Promise<[T, FieldPacket[]]>;
};
} & T;

View File

@@ -1,21 +1,18 @@
import { FieldPacket, QueryResult } from '../../packets/index.js';
import { QueryOptions, QueryableConstructor } from '../Query.js';
import { QueryOptions, QueryValues, QueryableConstructor } from '../Query.js';
export declare function QueryableBase<T extends QueryableConstructor>(
Base?: T
): {
new (...args: any[]): {
query<T extends QueryResult>(sql: string): Promise<[T, FieldPacket[]]>;
query<T extends QueryResult>(
sql: string,
values: any
): Promise<[T, FieldPacket[]]>;
query<T extends QueryResult>(
options: QueryOptions
values?: QueryValues
): Promise<[T, FieldPacket[]]>;
query<T extends QueryResult>(
options: QueryOptions,
values: any
values?: QueryValues
): Promise<[T, FieldPacket[]]>;
};
} & T;