mysql2 3.22.1-canary.cb5adccb → 3.22.1

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.
@@ -26,13 +26,14 @@ class PromiseConnection extends EventEmitter {
26
26
 
27
27
  query(query, params) {
28
28
  const c = this.connection;
29
+ const localErr = new Error();
29
30
  if (typeof params === 'function') {
30
31
  throw new Error(
31
32
  'Callback function is not available with promise clients.'
32
33
  );
33
34
  }
34
35
  return new this.Promise((resolve, reject) => {
35
- const done = makeDoneCb(resolve, reject);
36
+ const done = makeDoneCb(resolve, reject, localErr);
36
37
  if (params !== undefined) {
37
38
  c.query(query, params, done);
38
39
  } else {
@@ -43,13 +44,14 @@ class PromiseConnection extends EventEmitter {
43
44
 
44
45
  execute(query, params) {
45
46
  const c = this.connection;
47
+ const localErr = new Error();
46
48
  if (typeof params === 'function') {
47
49
  throw new Error(
48
50
  'Callback function is not available with promise clients.'
49
51
  );
50
52
  }
51
53
  return new this.Promise((resolve, reject) => {
52
- const done = makeDoneCb(resolve, reject);
54
+ const done = makeDoneCb(resolve, reject, localErr);
53
55
  if (params !== undefined) {
54
56
  c.execute(query, params, done);
55
57
  } else {
@@ -72,34 +74,37 @@ class PromiseConnection extends EventEmitter {
72
74
 
73
75
  beginTransaction() {
74
76
  const c = this.connection;
77
+ const localErr = new Error();
75
78
  return new this.Promise((resolve, reject) => {
76
- const done = makeDoneCb(resolve, reject);
79
+ const done = makeDoneCb(resolve, reject, localErr);
77
80
  c.beginTransaction(done);
78
81
  });
79
82
  }
80
83
 
81
84
  commit() {
82
85
  const c = this.connection;
86
+ const localErr = new Error();
83
87
  return new this.Promise((resolve, reject) => {
84
- const done = makeDoneCb(resolve, reject);
88
+ const done = makeDoneCb(resolve, reject, localErr);
85
89
  c.commit(done);
86
90
  });
87
91
  }
88
92
 
89
93
  rollback() {
90
94
  const c = this.connection;
95
+ const localErr = new Error();
91
96
  return new this.Promise((resolve, reject) => {
92
- const done = makeDoneCb(resolve, reject);
97
+ const done = makeDoneCb(resolve, reject, localErr);
93
98
  c.rollback(done);
94
99
  });
95
100
  }
96
101
 
97
102
  ping() {
98
103
  const c = this.connection;
104
+ const localErr = new Error();
99
105
  return new this.Promise((resolve, reject) => {
100
106
  c.ping((err) => {
101
107
  if (err) {
102
- const localErr = new Error();
103
108
  localErr.message = err.message;
104
109
  localErr.code = err.code;
105
110
  localErr.errno = err.errno;
@@ -115,10 +120,10 @@ class PromiseConnection extends EventEmitter {
115
120
 
116
121
  reset() {
117
122
  const c = this.connection;
123
+ const localErr = new Error();
118
124
  return new this.Promise((resolve, reject) => {
119
125
  c.reset((err) => {
120
126
  if (err) {
121
- const localErr = new Error();
122
127
  localErr.message = err.message;
123
128
  localErr.code = err.code;
124
129
  localErr.errno = err.errno;
@@ -134,10 +139,10 @@ class PromiseConnection extends EventEmitter {
134
139
 
135
140
  connect() {
136
141
  const c = this.connection;
142
+ const localErr = new Error();
137
143
  return new this.Promise((resolve, reject) => {
138
144
  c.connect((err, param) => {
139
145
  if (err) {
140
- const localErr = new Error();
141
146
  localErr.message = err.message;
142
147
  localErr.code = err.code;
143
148
  localErr.errno = err.errno;
@@ -154,10 +159,10 @@ class PromiseConnection extends EventEmitter {
154
159
  prepare(options) {
155
160
  const c = this.connection;
156
161
  const promiseImpl = this.Promise;
162
+ const localErr = new Error();
157
163
  return new this.Promise((resolve, reject) => {
158
164
  c.prepare(options, (err, statement) => {
159
165
  if (err) {
160
- const localErr = new Error();
161
166
  localErr.message = err.message;
162
167
  localErr.code = err.code;
163
168
  localErr.errno = err.errno;
@@ -177,10 +182,10 @@ class PromiseConnection extends EventEmitter {
177
182
 
178
183
  changeUser(options) {
179
184
  const c = this.connection;
185
+ const localErr = new Error();
180
186
  return new this.Promise((resolve, reject) => {
181
187
  c.changeUser(options, (err) => {
182
188
  if (err) {
183
- const localErr = new Error();
184
189
  localErr.message = err.message;
185
190
  localErr.code = err.code;
186
191
  localErr.errno = err.errno;
@@ -1,9 +1,8 @@
1
1
  'use strict';
2
2
 
3
- function makeDoneCb(resolve, reject) {
3
+ function makeDoneCb(resolve, reject, localErr) {
4
4
  return function (err, rows, fields) {
5
5
  if (err) {
6
- const localErr = new Error();
7
6
  localErr.message = err.message;
8
7
  localErr.code = err.code;
9
8
  localErr.errno = err.errno;
@@ -33,13 +33,14 @@ class PromisePool extends EventEmitter {
33
33
 
34
34
  query(sql, args) {
35
35
  const corePool = this.pool;
36
+ const localErr = new Error();
36
37
  if (typeof args === 'function') {
37
38
  throw new Error(
38
39
  'Callback function is not available with promise clients.'
39
40
  );
40
41
  }
41
42
  return new this.Promise((resolve, reject) => {
42
- const done = makeDoneCb(resolve, reject);
43
+ const done = makeDoneCb(resolve, reject, localErr);
43
44
  if (args !== undefined) {
44
45
  corePool.query(sql, args, done);
45
46
  } else {
@@ -50,13 +51,14 @@ class PromisePool extends EventEmitter {
50
51
 
51
52
  execute(sql, args) {
52
53
  const corePool = this.pool;
54
+ const localErr = new Error();
53
55
  if (typeof args === 'function') {
54
56
  throw new Error(
55
57
  'Callback function is not available with promise clients.'
56
58
  );
57
59
  }
58
60
  return new this.Promise((resolve, reject) => {
59
- const done = makeDoneCb(resolve, reject);
61
+ const done = makeDoneCb(resolve, reject, localErr);
60
62
  if (args) {
61
63
  corePool.execute(sql, args, done);
62
64
  } else {
@@ -67,10 +69,10 @@ class PromisePool extends EventEmitter {
67
69
 
68
70
  end() {
69
71
  const corePool = this.pool;
72
+ const localErr = new Error();
70
73
  return new this.Promise((resolve, reject) => {
71
74
  corePool.end((err) => {
72
75
  if (err) {
73
- const localErr = new Error();
74
76
  localErr.message = err.message;
75
77
  localErr.code = err.code;
76
78
  localErr.errno = err.errno;
@@ -24,26 +24,28 @@ class PromisePoolNamespace {
24
24
 
25
25
  query(sql, values) {
26
26
  const corePoolNamespace = this.poolNamespace;
27
+ const localErr = new Error();
27
28
  if (typeof values === 'function') {
28
29
  throw new Error(
29
30
  'Callback function is not available with promise clients.'
30
31
  );
31
32
  }
32
33
  return new this.Promise((resolve, reject) => {
33
- const done = makeDoneCb(resolve, reject);
34
+ const done = makeDoneCb(resolve, reject, localErr);
34
35
  corePoolNamespace.query(sql, values, done);
35
36
  });
36
37
  }
37
38
 
38
39
  execute(sql, values) {
39
40
  const corePoolNamespace = this.poolNamespace;
41
+ const localErr = new Error();
40
42
  if (typeof values === 'function') {
41
43
  throw new Error(
42
44
  'Callback function is not available with promise clients.'
43
45
  );
44
46
  }
45
47
  return new this.Promise((resolve, reject) => {
46
- const done = makeDoneCb(resolve, reject);
48
+ const done = makeDoneCb(resolve, reject, localErr);
47
49
  corePoolNamespace.execute(sql, values, done);
48
50
  });
49
51
  }
@@ -10,8 +10,9 @@ class PromisePreparedStatementInfo {
10
10
 
11
11
  execute(parameters) {
12
12
  const s = this.statement;
13
+ const localErr = new Error();
13
14
  return new this.Promise((resolve, reject) => {
14
- const done = makeDoneCb(resolve, reject);
15
+ const done = makeDoneCb(resolve, reject, localErr);
15
16
  if (parameters) {
16
17
  s.execute(parameters, done);
17
18
  } else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mysql2",
3
- "version": "3.22.1-canary.cb5adccb",
3
+ "version": "3.22.1",
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",
package/promise.js CHANGED
@@ -16,6 +16,7 @@ const PromisePoolNamespace = require('./lib/promise/pool_cluster');
16
16
 
17
17
  function createConnectionPromise(opts) {
18
18
  const coreConnection = createConnection(opts);
19
+ const createConnectionErr = new Error();
19
20
  const thePromise = opts.Promise || Promise;
20
21
  if (!thePromise) {
21
22
  throw new Error(
@@ -29,7 +30,6 @@ function createConnectionPromise(opts) {
29
30
  resolve(new PromiseConnection(coreConnection, thePromise));
30
31
  });
31
32
  coreConnection.once('error', (err) => {
32
- const createConnectionErr = new Error();
33
33
  createConnectionErr.message = err.message;
34
34
  createConnectionErr.code = err.code;
35
35
  createConnectionErr.errno = err.errno;
@@ -83,26 +83,28 @@ class PromisePoolCluster extends EventEmitter {
83
83
 
84
84
  query(sql, args) {
85
85
  const corePoolCluster = this.poolCluster;
86
+ const localErr = new Error();
86
87
  if (typeof args === 'function') {
87
88
  throw new Error(
88
89
  'Callback function is not available with promise clients.'
89
90
  );
90
91
  }
91
92
  return new this.Promise((resolve, reject) => {
92
- const done = makeDoneCb(resolve, reject);
93
+ const done = makeDoneCb(resolve, reject, localErr);
93
94
  corePoolCluster.query(sql, args, done);
94
95
  });
95
96
  }
96
97
 
97
98
  execute(sql, args) {
98
99
  const corePoolCluster = this.poolCluster;
100
+ const localErr = new Error();
99
101
  if (typeof args === 'function') {
100
102
  throw new Error(
101
103
  'Callback function is not available with promise clients.'
102
104
  );
103
105
  }
104
106
  return new this.Promise((resolve, reject) => {
105
- const done = makeDoneCb(resolve, reject);
107
+ const done = makeDoneCb(resolve, reject, localErr);
106
108
  corePoolCluster.execute(sql, args, done);
107
109
  });
108
110
  }
@@ -116,10 +118,10 @@ class PromisePoolCluster extends EventEmitter {
116
118
 
117
119
  end() {
118
120
  const corePoolCluster = this.poolCluster;
121
+ const localErr = new Error();
119
122
  return new this.Promise((resolve, reject) => {
120
123
  corePoolCluster.end((err) => {
121
124
  if (err) {
122
- const localErr = new Error();
123
125
  localErr.message = err.message;
124
126
  localErr.code = err.code;
125
127
  localErr.errno = err.errno;