mysql2 3.18.1 → 3.18.2-canary.3f94950d

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mysql2",
3
- "version": "3.18.1",
3
+ "version": "3.18.2-canary.3f94950d",
4
4
  "description": "fast mysql driver. Implements core protocol, prepared statements, ssl and compression in native JS",
5
5
  "main": "index.js",
6
6
  "typings": "typings/mysql/index",
@@ -5,6 +5,7 @@
5
5
 
6
6
  import { EventEmitter } from 'events';
7
7
  import { Readable } from 'stream';
8
+ import { Timezone } from 'sql-escaper';
8
9
  import { Query, QueryError } from './protocol/sequences/Query.js';
9
10
  import { Prepare, PrepareStatementInfo } from './protocol/sequences/Prepare.js';
10
11
  import {
@@ -150,7 +151,7 @@ export interface ConnectionOptions {
150
151
  /**
151
152
  * The timezone used to store local dates. (Default: 'local')
152
153
  */
153
- timezone?: string | 'local';
154
+ timezone?: Timezone;
154
155
 
155
156
  /**
156
157
  * The milliseconds before a timeout occurs during the initial connection to the MySQL server. (Default: 10 seconds)
@@ -3,6 +3,7 @@ import {
3
3
  Query,
4
4
  QueryError,
5
5
  QueryOptions,
6
+ ExecuteValues,
6
7
  QueryableConstructor,
7
8
  } from './Query.js';
8
9
 
@@ -18,7 +19,7 @@ export declare function ExecutableBase<T extends QueryableConstructor>(
18
19
  ): Query;
19
20
  execute<T extends QueryResult>(
20
21
  sql: string,
21
- values: any,
22
+ values: ExecuteValues,
22
23
  callback?:
23
24
  | ((err: QueryError | null, result: T, fields: FieldPacket[]) => any)
24
25
  | undefined
@@ -26,12 +27,12 @@ export declare function ExecutableBase<T extends QueryableConstructor>(
26
27
  execute<T extends QueryResult>(
27
28
  options: QueryOptions,
28
29
  callback?:
29
- | ((err: QueryError | null, result: T, fields?: FieldPacket[]) => any)
30
+ | ((err: QueryError | null, result: T, fields: FieldPacket[]) => any)
30
31
  | undefined
31
32
  ): Query;
32
33
  execute<T extends QueryResult>(
33
34
  options: QueryOptions,
34
- values: any,
35
+ values: ExecuteValues,
35
36
  callback?:
36
37
  | ((err: QueryError | null, result: T, fields: FieldPacket[]) => any)
37
38
  | undefined
@@ -1,8 +1,22 @@
1
1
  import { Sequence } from './Sequence.js';
2
2
  import { OkPacket, RowDataPacket, FieldPacket } from '../packets/index.js';
3
3
  import { Readable } from 'stream';
4
+ import { Raw, Timezone } from 'sql-escaper';
4
5
  import { TypeCast } from '../../parsers/typeCast.js';
5
6
 
7
+ export type ExecuteValues =
8
+ | string
9
+ | number
10
+ | bigint
11
+ | boolean
12
+ | Date
13
+ | null
14
+ | Blob
15
+ | Buffer
16
+ | Uint8Array
17
+ | ExecuteValues[]
18
+ | { [key: string]: ExecuteValues };
19
+
6
20
  export type QueryValues =
7
21
  | string
8
22
  | number
@@ -10,9 +24,12 @@ export type QueryValues =
10
24
  | boolean
11
25
  | Date
12
26
  | null
27
+ | undefined
13
28
  | Blob
14
29
  | Buffer
15
- | ({} | null)[]
30
+ | Uint8Array
31
+ | Raw
32
+ | ({} | null | undefined)[]
16
33
  | { [key: string]: QueryValues };
17
34
 
18
35
  export interface QueryOptions {
@@ -95,6 +112,35 @@ export interface QueryOptions {
95
112
  * By specifying a function that returns a readable stream, an arbitrary stream can be sent when sending a local fs file.
96
113
  */
97
114
  infileStreamFactory?: (path: string) => Readable;
115
+
116
+ /**
117
+ * When dealing with big numbers (BIGINT and DECIMAL columns) in the database, you should enable this option
118
+ * (Default: false)
119
+ */
120
+ supportBigNumbers?: boolean;
121
+
122
+ /**
123
+ * Enabling both supportBigNumbers and bigNumberStrings forces big numbers (BIGINT and DECIMAL columns) to be
124
+ * always returned as JavaScript String objects (Default: false). Enabling supportBigNumbers but leaving
125
+ * bigNumberStrings disabled will return big numbers as String objects only when they cannot be accurately
126
+ * represented with JavaScript Number objects (which happens when they exceed the [-2^53, +2^53] range),
127
+ * otherwise they will be returned as Number objects.
128
+ * This option is ignored if supportBigNumbers is disabled.
129
+ */
130
+ bigNumberStrings?: boolean;
131
+
132
+ /**
133
+ * Force date types (TIMESTAMP, DATETIME, DATE) to be returned as strings rather then inflated into JavaScript Date
134
+ * objects. Can be true/false or an array of type names to keep as strings.
135
+ *
136
+ * (Default: false)
137
+ */
138
+ dateStrings?: boolean | Array<'TIMESTAMP' | 'DATETIME' | 'DATE'>;
139
+
140
+ /**
141
+ * The timezone used to store local dates. (Default: 'local')
142
+ */
143
+ timezone?: Timezone;
98
144
  }
99
145
 
100
146
  export interface StreamOptions {
@@ -3,6 +3,7 @@ import {
3
3
  Query,
4
4
  QueryError,
5
5
  QueryOptions,
6
+ QueryValues,
6
7
  QueryableConstructor,
7
8
  } from './Query.js';
8
9
 
@@ -18,7 +19,7 @@ export declare function QueryableBase<T extends QueryableConstructor>(
18
19
  ): Query;
19
20
  query<T extends QueryResult>(
20
21
  sql: string,
21
- values: any,
22
+ values: QueryValues,
22
23
  callback?:
23
24
  | ((err: QueryError | null, result: T, fields: FieldPacket[]) => any)
24
25
  | undefined
@@ -26,12 +27,12 @@ export declare function QueryableBase<T extends QueryableConstructor>(
26
27
  query<T extends QueryResult>(
27
28
  options: QueryOptions,
28
29
  callback?:
29
- | ((err: QueryError | null, result: T, fields?: FieldPacket[]) => any)
30
+ | ((err: QueryError | null, result: T, fields: FieldPacket[]) => any)
30
31
  | undefined
31
32
  ): Query;
32
33
  query<T extends QueryResult>(
33
34
  options: QueryOptions,
34
- values: any,
35
+ values: QueryValues,
35
36
  callback?:
36
37
  | ((err: QueryError | null, result: T, fields: FieldPacket[]) => any)
37
38
  | undefined
@@ -1,21 +1,17 @@
1
1
  import { FieldPacket, QueryResult } from '../../packets/index.js';
2
- import { QueryOptions, QueryableConstructor, QueryValues } from '../Query.js';
2
+ import { QueryOptions, QueryableConstructor, ExecuteValues } from '../Query.js';
3
3
 
4
4
  export declare function ExecutableBase<T extends QueryableConstructor>(
5
5
  Base?: T
6
6
  ): {
7
7
  new (...args: any[]): {
8
- execute<T extends QueryResult>(sql: string): Promise<[T, FieldPacket[]]>;
9
8
  execute<T extends QueryResult>(
10
9
  sql: string,
11
- values?: QueryValues
12
- ): Promise<[T, FieldPacket[]]>;
13
- execute<T extends QueryResult>(
14
- options: QueryOptions
10
+ values?: ExecuteValues
15
11
  ): Promise<[T, FieldPacket[]]>;
16
12
  execute<T extends QueryResult>(
17
13
  options: QueryOptions,
18
- values?: QueryValues
14
+ values?: ExecuteValues
19
15
  ): Promise<[T, FieldPacket[]]>;
20
16
  };
21
17
  } & T;
@@ -1,21 +1,18 @@
1
1
  import { FieldPacket, QueryResult } from '../../packets/index.js';
2
- import { QueryOptions, QueryableConstructor } from '../Query.js';
2
+ import { QueryOptions, QueryValues, QueryableConstructor } from '../Query.js';
3
3
 
4
4
  export declare function QueryableBase<T extends QueryableConstructor>(
5
5
  Base?: T
6
6
  ): {
7
7
  new (...args: any[]): {
8
- query<T extends QueryResult>(sql: string): Promise<[T, FieldPacket[]]>;
9
8
  query<T extends QueryResult>(
10
9
  sql: string,
11
- values?: any
12
- ): Promise<[T, FieldPacket[]]>;
13
- query<T extends QueryResult>(
14
- options: QueryOptions
10
+ values?: QueryValues
15
11
  ): Promise<[T, FieldPacket[]]>;
12
+
16
13
  query<T extends QueryResult>(
17
14
  options: QueryOptions,
18
- values?: any
15
+ values?: QueryValues
19
16
  ): Promise<[T, FieldPacket[]]>;
20
17
  };
21
18
  } & T;