mysql2 3.5.2 → 3.6.0

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/lib/connection.js CHANGED
@@ -615,10 +615,15 @@ class Connection extends EventEmitter {
615
615
  }
616
616
 
617
617
  execute(sql, values, cb) {
618
- let options = {};
618
+ let options = {
619
+ infileStreamFactory: this.config.infileStreamFactory
620
+ };
619
621
  if (typeof sql === 'object') {
620
622
  // execute(options, cb)
621
- options = sql;
623
+ options = {
624
+ ...options,
625
+ ...sql
626
+ };
622
627
  if (typeof values === 'function') {
623
628
  cb = values;
624
629
  } else {
@@ -899,11 +904,15 @@ class Connection extends EventEmitter {
899
904
 
900
905
  static createQuery(sql, values, cb, config) {
901
906
  let options = {
902
- rowsAsArray: config.rowsAsArray
907
+ rowsAsArray: config.rowsAsArray,
908
+ infileStreamFactory: config.infileStreamFactory
903
909
  };
904
910
  if (typeof sql === 'object') {
905
911
  // query(options, cb)
906
- options = sql;
912
+ options = {
913
+ ...options,
914
+ ...sql
915
+ };
907
916
  if (typeof values === 'function') {
908
917
  cb = values;
909
918
  } else if (values !== undefined) {
@@ -30,6 +30,7 @@ const validOptions = {
30
30
  flags: 1,
31
31
  host: 1,
32
32
  insecureAuth: 1,
33
+ infileStreamFactory: 1,
33
34
  isServer: 1,
34
35
  keepAliveInitialDelay: 1,
35
36
  localAddress: 1,
@@ -108,6 +109,7 @@ class ConnectionConfig {
108
109
  ? 10 * 1000
109
110
  : options.connectTimeout;
110
111
  this.insecureAuth = options.insecureAuth || false;
112
+ this.infileStreamFactory = options.infileStreamFactory || undefined;
111
113
  this.supportBigNumbers = options.supportBigNumbers || false;
112
114
  this.bigNumberStrings = options.bigNumberStrings || false;
113
115
  this.decimalNumbers = options.decimalNumbers || false;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mysql2",
3
- "version": "3.5.2",
3
+ "version": "3.6.0",
4
4
  "description": "fast mysql driver. Implements core protocol, prepared statements, ssl and compression in native JS",
5
5
  "main": "index.js",
6
6
  "directories": {
@@ -4,6 +4,7 @@
4
4
  // Modifications copyright (c) 2021, Oracle and/or its affiliates.
5
5
 
6
6
  import { EventEmitter } from 'events';
7
+ import { Readable } from 'stream';
7
8
  import { Query, QueryError } from './protocol/sequences/Query.js';
8
9
  import { Prepare, PrepareStatementInfo } from './protocol/sequences/Prepare.js';
9
10
  import {
@@ -165,6 +166,11 @@ export interface ConnectionOptions {
165
166
  */
166
167
  insecureAuth?: boolean;
167
168
 
169
+ /**
170
+ * By specifying a function that returns a readable stream, an arbitrary stream can be sent when sending a local fs file.
171
+ */
172
+ infileStreamFactory?: (path: string) => Readable;
173
+
168
174
  /**
169
175
  * Determines if column values should be converted to native JavaScript types. It is not recommended (and may go away / change in the future)
170
176
  * to disable type casting, but you can currently do so on either the connection or query level. (Default: true)