mysql2 3.18.1 → 3.18.2-canary.2ad5f0b2

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.2ad5f0b2",
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,9 +1,10 @@
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 { Timezone } from 'sql-escaper';
4
5
  import { TypeCast } from '../../parsers/typeCast.js';
5
6
 
6
- export type QueryValues =
7
+ export type ExecuteValues =
7
8
  | string
8
9
  | number
9
10
  | bigint
@@ -13,6 +14,18 @@ export type QueryValues =
13
14
  | Blob
14
15
  | Buffer
15
16
  | ({} | null)[]
17
+ | { [key: string]: ExecuteValues };
18
+
19
+ export type QueryValues =
20
+ | string
21
+ | number
22
+ | bigint
23
+ | boolean
24
+ | Date
25
+ | null
26
+ | Blob
27
+ | Buffer
28
+ | ({} | null | undefined)[]
16
29
  | { [key: string]: QueryValues };
17
30
 
18
31
  export interface QueryOptions {
@@ -95,6 +108,35 @@ export interface QueryOptions {
95
108
  * By specifying a function that returns a readable stream, an arbitrary stream can be sent when sending a local fs file.
96
109
  */
97
110
  infileStreamFactory?: (path: string) => Readable;
111
+
112
+ /**
113
+ * When dealing with big numbers (BIGINT and DECIMAL columns) in the database, you should enable this option
114
+ * (Default: false)
115
+ */
116
+ supportBigNumbers?: boolean;
117
+
118
+ /**
119
+ * Enabling both supportBigNumbers and bigNumberStrings forces big numbers (BIGINT and DECIMAL columns) to be
120
+ * always returned as JavaScript String objects (Default: false). Enabling supportBigNumbers but leaving
121
+ * bigNumberStrings disabled will return big numbers as String objects only when they cannot be accurately
122
+ * represented with JavaScript Number objects (which happens when they exceed the [-2^53, +2^53] range),
123
+ * otherwise they will be returned as Number objects.
124
+ * This option is ignored if supportBigNumbers is disabled.
125
+ */
126
+ bigNumberStrings?: boolean;
127
+
128
+ /**
129
+ * Force date types (TIMESTAMP, DATETIME, DATE) to be returned as strings rather then inflated into JavaScript Date
130
+ * objects. Can be true/false or an array of type names to keep as strings.
131
+ *
132
+ * (Default: false)
133
+ */
134
+ dateStrings?: boolean | Array<'TIMESTAMP' | 'DATETIME' | 'DATE'>;
135
+
136
+ /**
137
+ * The timezone used to store local dates. (Default: 'local')
138
+ */
139
+ timezone?: Timezone;
98
140
  }
99
141
 
100
142
  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;