@cubejs-backend/mssql-driver 0.33.11 → 0.33.17

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/CHANGELOG.md CHANGED
@@ -3,6 +3,28 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [0.33.17](https://github.com/cube-js/cube/compare/v0.33.16...v0.33.17) (2023-05-29)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * **mssql-driver:** Server crashes on streaming errors ([2e81345](https://github.com/cube-js/cube/commit/2e81345059c14c0880e8b7d1bde7c9d04e497bfa))
12
+
13
+
14
+
15
+
16
+
17
+ ## [0.33.16](https://github.com/cube-js/cube/compare/v0.33.15...v0.33.16) (2023-05-28)
18
+
19
+
20
+ ### Bug Fixes
21
+
22
+ * **mssql-driver:** Pre-aggregations builds hang up if over 10K of rows ([#6661](https://github.com/cube-js/cube/issues/6661)) ([9b20ff4](https://github.com/cube-js/cube/commit/9b20ff4ef78acbb65ebea80adceb227bf96b1727))
23
+
24
+
25
+
26
+
27
+
6
28
  ## [0.33.11](https://github.com/cube-js/cube/compare/v0.33.10...v0.33.11) (2023-05-22)
7
29
 
8
30
  **Note:** Version bump only for package @cubejs-backend/mssql-driver
@@ -58,7 +58,7 @@ class MSSqlDriver extends BaseDriver {
58
58
  user: getEnv('dbUser', { dataSource }),
59
59
  password: getEnv('dbPass', { dataSource }),
60
60
  domain: getEnv('dbDomain', { dataSource }),
61
- requestTimeout: 10 * 60 * 1000, // 10 minutes
61
+ requestTimeout: getEnv('dbQueryTimeout') * 1000,
62
62
  options: {
63
63
  encrypt: getEnv('dbSsl', { dataSource }),
64
64
  useUTC: false
@@ -124,6 +124,9 @@ class MSSqlDriver extends BaseDriver {
124
124
  request.on('error', (err) => {
125
125
  reject(err);
126
126
  });
127
+ stream.on('error', (err) => {
128
+ reject(err);
129
+ })
127
130
  });
128
131
  return {
129
132
  rowStream: stream,
@@ -168,7 +171,7 @@ class MSSqlDriver extends BaseDriver {
168
171
  case sql.Money:
169
172
  case sql.SmallMoney:
170
173
  case sql.Numeric:
171
- type = 'float';
174
+ type = 'decimal';
172
175
  break;
173
176
  // double
174
177
  case sql.Float:
@@ -186,16 +189,16 @@ class MSSqlDriver extends BaseDriver {
186
189
  break;
187
190
  // date and time
188
191
  case sql.Time:
189
- type = 'date';
192
+ type = 'time';
190
193
  break;
191
194
  case sql.Date:
192
- type = 'date';
195
+ type = 'timestamp';
193
196
  break;
194
197
  case sql.DateTime:
195
198
  case sql.DateTime2:
196
199
  case sql.SmallDateTime:
197
200
  case sql.DateTimeOffset:
198
- type = 'date';
201
+ type = 'timestamp';
199
202
  break;
200
203
  // others
201
204
  case sql.UniqueIdentifier:
@@ -213,7 +216,7 @@ class MSSqlDriver extends BaseDriver {
213
216
  type = 'string';
214
217
  break;
215
218
  }
216
- return { name: fields[field].name, type };
219
+ return { name: fields[field].name, type: this.toGenericType(type) };
217
220
  });
218
221
  }
219
222
 
@@ -6,8 +6,7 @@ const { getEnv } = require('@cubejs-backend/shared');
6
6
  */
7
7
  class QueryStream extends Readable {
8
8
  request = null;
9
- recordset = [];
10
- done = false;
9
+ toRead = 0;
11
10
 
12
11
  /**
13
12
  * @constructor
@@ -19,32 +18,34 @@ class QueryStream extends Readable {
19
18
  highWaterMark || getEnv('dbQueryStreamHighWaterMark'),
20
19
  });
21
20
  this.request = request;
22
- this.request.on('row', (row) => {
23
- this.recordset?.push(row);
24
- if (this.recordset?.length === getEnv('dbQueryStreamHighWaterMark')) {
21
+ this.request.on('row', row => {
22
+ this.transformRow(row);
23
+ const canAdd = this.push(row);
24
+ if (this.toRead-- <= 0 || !canAdd) {
25
25
  this.request.pause();
26
26
  }
27
- });
27
+ })
28
+ this.request.on('done', () => {
29
+ this.push(null);
30
+ })
28
31
  this.request.on('error', (err) => {
29
32
  this.destroy(err);
30
33
  });
31
- this.request.on('done', () => {
32
- this.done = true;
33
- });
34
34
  }
35
35
 
36
36
  /**
37
37
  * @override
38
38
  */
39
- _read(highWaterMark) {
40
- const chunk = this.recordset?.splice(0, highWaterMark);
41
- chunk?.forEach((row) => {
42
- this.push(row);
43
- });
44
- if (this.recordset?.length === 0 && this.done) {
45
- this.push(null);
46
- } else {
47
- this.request.resume();
39
+ _read(toRead) {
40
+ this.toRead += toRead;
41
+ this.request.resume();
42
+ }
43
+
44
+ transformRow(row) {
45
+ for (const key in row) {
46
+ if (row.hasOwnProperty(key) && row[key] && row[key] instanceof Date) {
47
+ row[key] = row[key].toJSON();
48
+ }
48
49
  }
49
50
  }
50
51
 
@@ -52,8 +53,8 @@ class QueryStream extends Readable {
52
53
  * @override
53
54
  */
54
55
  _destroy(error, callback) {
56
+ this.request.cancel();
55
57
  this.request = null;
56
- this.recordset = null;
57
58
  callback(error);
58
59
  }
59
60
  }
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@cubejs-backend/mssql-driver",
3
3
  "description": "Cube.js MS SQL database driver",
4
4
  "author": "Cube Dev, Inc.",
5
- "version": "0.33.11",
5
+ "version": "0.33.17",
6
6
  "repository": {
7
7
  "type": "git",
8
8
  "url": "https://github.com/cube-js/cube.git",
@@ -20,5 +20,5 @@
20
20
  "publishConfig": {
21
21
  "access": "public"
22
22
  },
23
- "gitHead": "affcdbfacfe51721da7e94bdeb4b5761f2905231"
23
+ "gitHead": "51e3a298b10d96b7e6fae6fbdd7bf9733675a554"
24
24
  }