@tdengine/websocket 3.2.0 → 3.2.2
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/example/all_type_query.js +26 -22
- package/lib/example/all_type_stmt.js +22 -20
- package/lib/example/basicBatchTmq.js +14 -14
- package/lib/example/basicSchemaless.js +11 -11
- package/lib/example/basicSql.js +10 -10
- package/lib/example/basicStmt.js +3 -3
- package/lib/example/basicTmq.js +8 -9
- package/lib/index.d.ts +0 -7
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +0 -7
- package/lib/src/client/wsClient.d.ts +2 -2
- package/lib/src/client/wsClient.d.ts.map +1 -1
- package/lib/src/client/wsClient.js +60 -37
- package/lib/src/client/wsConnector.d.ts.map +1 -1
- package/lib/src/client/wsConnector.js +40 -14
- package/lib/src/client/wsConnectorPool.d.ts.map +1 -1
- package/lib/src/client/wsConnectorPool.js +29 -14
- package/lib/src/client/wsEventCallback.d.ts.map +1 -1
- package/lib/src/client/wsEventCallback.js +6 -4
- package/lib/src/client/wsResponse.d.ts.map +1 -1
- package/lib/src/client/wsResponse.js +6 -2
- package/lib/src/common/config.d.ts +2 -2
- package/lib/src/common/config.d.ts.map +1 -1
- package/lib/src/common/config.js +5 -5
- package/lib/src/common/constant.d.ts.map +1 -1
- package/lib/src/common/constant.js +27 -27
- package/lib/src/common/log.d.ts +1 -1
- package/lib/src/common/log.d.ts.map +1 -1
- package/lib/src/common/log.js +9 -7
- package/lib/src/common/reqid.d.ts.map +1 -1
- package/lib/src/common/reqid.js +7 -7
- package/lib/src/common/taosResult.d.ts.map +1 -1
- package/lib/src/common/taosResult.js +46 -27
- package/lib/src/common/ut8Helper.d.ts.map +1 -1
- package/lib/src/common/ut8Helper.js +8 -8
- package/lib/src/common/utils.d.ts.map +1 -1
- package/lib/src/common/utils.js +17 -16
- package/lib/src/common/wsError.d.ts.map +1 -1
- package/lib/src/common/wsError.js +3 -3
- package/lib/src/common/wsOptions.d.ts +1 -1
- package/lib/src/index.d.ts +3 -3
- package/lib/src/index.d.ts.map +1 -1
- package/lib/src/sql/wsProto.d.ts.map +1 -1
- package/lib/src/sql/wsRows.d.ts +3 -3
- package/lib/src/sql/wsRows.d.ts.map +1 -1
- package/lib/src/sql/wsRows.js +4 -2
- package/lib/src/sql/wsSql.d.ts +5 -5
- package/lib/src/sql/wsSql.d.ts.map +1 -1
- package/lib/src/sql/wsSql.js +15 -16
- package/lib/src/stmt/FieldBindParams.d.ts.map +1 -1
- package/lib/src/stmt/wsColumnInfo.d.ts.map +1 -1
- package/lib/src/stmt/wsParams1.d.ts.map +1 -1
- package/lib/src/stmt/wsParams1.js +50 -24
- package/lib/src/stmt/wsParams2.d.ts.map +1 -1
- package/lib/src/stmt/wsParams2.js +30 -15
- package/lib/src/stmt/wsParamsBase.d.ts.map +1 -1
- package/lib/src/stmt/wsParamsBase.js +5 -3
- package/lib/src/stmt/wsProto.d.ts.map +1 -1
- package/lib/src/stmt/wsProto.js +22 -11
- package/lib/src/stmt/wsStmt.d.ts.map +1 -1
- package/lib/src/stmt/wsStmt1.d.ts +5 -5
- package/lib/src/stmt/wsStmt1.d.ts.map +1 -1
- package/lib/src/stmt/wsStmt1.js +14 -14
- package/lib/src/stmt/wsStmt2.d.ts +1 -1
- package/lib/src/stmt/wsStmt2.d.ts.map +1 -1
- package/lib/src/stmt/wsStmt2.js +18 -14
- package/lib/src/stmt/wsTableInfo.d.ts.map +1 -1
- package/lib/src/tmq/config.d.ts.map +1 -1
- package/lib/src/tmq/config.js +2 -2
- package/lib/src/tmq/constant.d.ts.map +1 -1
- package/lib/src/tmq/constant.js +28 -28
- package/lib/src/tmq/tmqResponse.d.ts.map +1 -1
- package/lib/src/tmq/tmqResponse.js +30 -16
- package/lib/src/tmq/wsTmq.d.ts +2 -2
- package/lib/src/tmq/wsTmq.d.ts.map +1 -1
- package/lib/src/tmq/wsTmq.js +32 -30
- package/lib/test/bulkPulling/cloud.tmq.test.js +11 -11
- package/lib/test/bulkPulling/decimal.test.js +50 -26
- package/lib/test/bulkPulling/log.test.js +8 -8
- package/lib/test/bulkPulling/queryTables.test.js +255 -49
- package/lib/test/bulkPulling/schemaless.test.js +34 -34
- package/lib/test/bulkPulling/sql.test.js +108 -69
- package/lib/test/bulkPulling/stmt1.func.test.js +96 -96
- package/lib/test/bulkPulling/stmt1.type.test.js +124 -48
- package/lib/test/bulkPulling/stmt2.func.test.js +116 -112
- package/lib/test/bulkPulling/stmt2.type.test.js +124 -48
- package/lib/test/bulkPulling/tmq.test.js +225 -31
- package/lib/test/bulkPulling/utils.test.js +2 -2
- package/lib/test/bulkPulling/wsConnectPool.test.js +18 -18
- package/lib/test/utils.d.ts.map +1 -1
- package/lib/test/utils.js +129 -129
- package/package.json +1 -1
- package/readme.md +1 -0
- package/lib/src/stmt/wsParams.d.ts +0 -41
- package/lib/src/stmt/wsParams.d.ts.map +0 -1
- package/lib/src/stmt/wsParams.js +0 -428
- package/lib/test/bulkPulling/stmt.func.test.d.ts +0 -2
- package/lib/test/bulkPulling/stmt.func.test.d.ts.map +0 -1
- package/lib/test/bulkPulling/stmt.func.test.js +0 -493
- package/lib/test/bulkPulling/stmt.type.test.d.ts +0 -2
- package/lib/test/bulkPulling/stmt.type.test.d.ts.map +0 -1
- package/lib/test/bulkPulling/stmt.type.test.js +0 -316
|
@@ -6,18 +6,46 @@ const log_1 = require("../../src/common/log");
|
|
|
6
6
|
const wsSql_1 = require("../../src/sql/wsSql");
|
|
7
7
|
const wsStmt1_1 = require("../../src/stmt/wsStmt1");
|
|
8
8
|
const utils_1 = require("../utils");
|
|
9
|
-
const stable =
|
|
10
|
-
const table =
|
|
11
|
-
const db =
|
|
9
|
+
const stable = "ws_stmt_stb";
|
|
10
|
+
const table = "stmt_001";
|
|
11
|
+
const db = "ws_stmt1";
|
|
12
12
|
const createDB = `create database if not exists ${db} keep 3650`;
|
|
13
13
|
const useDB = `use ${db}`;
|
|
14
14
|
const dropDB = `drop database if exists ${db}`;
|
|
15
|
-
const tableCN =
|
|
16
|
-
const stableCN =
|
|
17
|
-
const jsonTable =
|
|
18
|
-
const jsonTableCN =
|
|
19
|
-
const stableTags = [
|
|
20
|
-
|
|
15
|
+
const tableCN = "stmt_cn";
|
|
16
|
+
const stableCN = "ws_stmt_stb_cn";
|
|
17
|
+
const jsonTable = "stmt_json";
|
|
18
|
+
const jsonTableCN = "stmt_json_cn";
|
|
19
|
+
const stableTags = [
|
|
20
|
+
true,
|
|
21
|
+
-1,
|
|
22
|
+
-2,
|
|
23
|
+
-3,
|
|
24
|
+
-4,
|
|
25
|
+
1,
|
|
26
|
+
2,
|
|
27
|
+
3,
|
|
28
|
+
4,
|
|
29
|
+
parseFloat((3.1415).toFixed(5)),
|
|
30
|
+
parseFloat((3.14159265).toFixed(15)),
|
|
31
|
+
"varchar_tag_1",
|
|
32
|
+
"nchar_tag_1",
|
|
33
|
+
];
|
|
34
|
+
const stableCNTags = [
|
|
35
|
+
false,
|
|
36
|
+
-1 * 2,
|
|
37
|
+
-2 * 2,
|
|
38
|
+
-3 * 2,
|
|
39
|
+
-4 * 2,
|
|
40
|
+
1 * 2,
|
|
41
|
+
2 * 2,
|
|
42
|
+
3 * 2,
|
|
43
|
+
4 * 2,
|
|
44
|
+
parseFloat((3.1415 * 2).toFixed(5)),
|
|
45
|
+
parseFloat((3.14159265 * 2).toFixed(15)),
|
|
46
|
+
"varchar_标签_壹",
|
|
47
|
+
"nchar_标签_贰",
|
|
48
|
+
];
|
|
21
49
|
const tableValues = [
|
|
22
50
|
[1656677710000, 1656677720000, 1656677730000, 1656677740000, 1656677750000],
|
|
23
51
|
[0, -1, -2, -3, -4],
|
|
@@ -30,15 +58,39 @@ const tableValues = [
|
|
|
30
58
|
[2, 3, 4, 5, 6],
|
|
31
59
|
// [0, 1, 2, 3, 4],
|
|
32
60
|
[BigInt(3), BigInt(4), BigInt(5), BigInt(6), BigInt(7)],
|
|
33
|
-
[
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
61
|
+
[
|
|
62
|
+
parseFloat((3.1415).toFixed(5)),
|
|
63
|
+
parseFloat((3.1415 * 2).toFixed(5)),
|
|
64
|
+
parseFloat((3.1415 * 3).toFixed(5)),
|
|
65
|
+
parseFloat((3.1415 * 4).toFixed(5)),
|
|
66
|
+
parseFloat((3.1415 * 5).toFixed(5)),
|
|
67
|
+
],
|
|
68
|
+
[
|
|
69
|
+
parseFloat((3.14159265).toFixed(15)),
|
|
70
|
+
parseFloat((3.14159265 * 2).toFixed(15)),
|
|
71
|
+
parseFloat((3.14159265 * 3).toFixed(15)),
|
|
72
|
+
parseFloat((3.14159265 * 4).toFixed(15)),
|
|
73
|
+
parseFloat((3.14159265 * 5).toFixed(15)),
|
|
74
|
+
],
|
|
75
|
+
[
|
|
76
|
+
"varchar_col_1",
|
|
77
|
+
"varchar_col_2",
|
|
78
|
+
"varchar_col_3",
|
|
79
|
+
"varchar_col_4",
|
|
80
|
+
"varchar_col_5",
|
|
81
|
+
],
|
|
82
|
+
["nchar_col_1", "nchar_col_2", "", "nchar_col_4", "nchar_col_5"],
|
|
37
83
|
[true, false, true, false, true],
|
|
38
|
-
[null, null, null, null, null]
|
|
84
|
+
[null, null, null, null, null],
|
|
39
85
|
];
|
|
40
86
|
const tableCNValues = [
|
|
41
|
-
[
|
|
87
|
+
[
|
|
88
|
+
BigInt(1656677760000),
|
|
89
|
+
BigInt(1656677770000),
|
|
90
|
+
BigInt(1656677780000),
|
|
91
|
+
BigInt(1656677790000),
|
|
92
|
+
BigInt(1656677100000),
|
|
93
|
+
],
|
|
42
94
|
[0, -1, -2, -3, -4],
|
|
43
95
|
[-1, -2, -3, -4, -5],
|
|
44
96
|
[-2, -3, -4, -5, -6],
|
|
@@ -47,10 +99,28 @@ const tableCNValues = [
|
|
|
47
99
|
[1, 2, 3, 4, 5],
|
|
48
100
|
[2, 3, 4, 5, 6],
|
|
49
101
|
[BigInt(3), BigInt(4), BigInt(5), BigInt(6), BigInt(7)],
|
|
50
|
-
[
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
102
|
+
[
|
|
103
|
+
parseFloat((3.1415).toFixed(5)),
|
|
104
|
+
parseFloat((3.1415 * 2).toFixed(5)),
|
|
105
|
+
parseFloat((3.1415 * 3).toFixed(5)),
|
|
106
|
+
parseFloat((3.1415 * 4).toFixed(5)),
|
|
107
|
+
parseFloat((3.1415 * 5).toFixed(5)),
|
|
108
|
+
],
|
|
109
|
+
[
|
|
110
|
+
parseFloat((3.14159265).toFixed(15)),
|
|
111
|
+
parseFloat((3.14159265 * 2).toFixed(15)),
|
|
112
|
+
parseFloat((3.14159265 * 3).toFixed(15)),
|
|
113
|
+
parseFloat((3.14159265 * 4).toFixed(15)),
|
|
114
|
+
parseFloat((3.14159265 * 5).toFixed(15)),
|
|
115
|
+
],
|
|
116
|
+
[
|
|
117
|
+
"varchar_列_壹",
|
|
118
|
+
"varchar_列_贰",
|
|
119
|
+
"varchar_列_叁",
|
|
120
|
+
"varchar_列_肆",
|
|
121
|
+
"varchar_列_伍",
|
|
122
|
+
],
|
|
123
|
+
["nchar_列_甲", "nchar_列_乙", "nchar_列_丙", "nchar_列_丁", "nchar_列_戊"],
|
|
54
124
|
[true, false, true, false, true],
|
|
55
125
|
[null, null, null, null, null],
|
|
56
126
|
];
|
|
@@ -58,21 +128,27 @@ let geoDataArray = [];
|
|
|
58
128
|
let varbinary = [];
|
|
59
129
|
const encoder = new TextEncoder();
|
|
60
130
|
for (let i = 0; i < 5; i++) {
|
|
61
|
-
let data = new Uint8Array([
|
|
62
|
-
|
|
131
|
+
let data = new Uint8Array([
|
|
132
|
+
0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x59,
|
|
133
|
+
0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x59, 0x40,
|
|
134
|
+
]);
|
|
63
135
|
geoDataArray.push(data.buffer);
|
|
64
136
|
let vdata = encoder.encode(`varchar_col_${i + 1}`);
|
|
65
137
|
varbinary.push(vdata.buffer);
|
|
66
138
|
}
|
|
67
|
-
const jsonTags = [
|
|
68
|
-
|
|
139
|
+
const jsonTags = [
|
|
140
|
+
'{"key1":"taos","key2":null,"key3":"TDengine","key4":0,"key5":false}',
|
|
141
|
+
];
|
|
142
|
+
const jsonTagsCN = [
|
|
143
|
+
'{"key1":"taosdata","key2":null,"key3":"TDengine涛思数据","key4":1,"key5":true}',
|
|
144
|
+
];
|
|
69
145
|
const selectStable = `select * from ${stable}`;
|
|
70
146
|
const selectStableCN = `select * from ${stableCN}`;
|
|
71
147
|
const selectTable = `select * from ${table}`;
|
|
72
148
|
const selectTableCN = `select * from ${tableCN}`;
|
|
73
149
|
const selectJsonTable = `select * from ${jsonTable}`;
|
|
74
150
|
const selectJsonTableCN = `select * from ${jsonTableCN}`;
|
|
75
|
-
let dsn =
|
|
151
|
+
let dsn = "ws://root:taosdata@localhost:6041";
|
|
76
152
|
(0, log_1.setLevel)("debug");
|
|
77
153
|
beforeAll(async () => {
|
|
78
154
|
let conf = new config_1.WSConfig(dsn);
|
|
@@ -84,9 +160,9 @@ beforeAll(async () => {
|
|
|
84
160
|
await ws.exec((0, utils_1.createSTableJSON)(jsonTable));
|
|
85
161
|
await ws.close();
|
|
86
162
|
});
|
|
87
|
-
describe(
|
|
163
|
+
describe("TDWebSocket.Stmt()", () => {
|
|
88
164
|
jest.setTimeout(20 * 1000);
|
|
89
|
-
test(
|
|
165
|
+
test("normal BindParam", async () => {
|
|
90
166
|
let wsConf = new config_1.WSConfig(dsn, "100.100.100.100");
|
|
91
167
|
wsConf.setDb(db);
|
|
92
168
|
let connector = await wsSql_1.WsSql.open(wsConf);
|
|
@@ -139,7 +215,7 @@ describe('TDWebSocket.Stmt()', () => {
|
|
|
139
215
|
console.log(result);
|
|
140
216
|
await connector.close();
|
|
141
217
|
});
|
|
142
|
-
test(
|
|
218
|
+
test("normal CN BindParam", async () => {
|
|
143
219
|
let wsConf = new config_1.WSConfig(dsn, "100.100.100.100");
|
|
144
220
|
wsConf.setDb(db);
|
|
145
221
|
let connector = await wsSql_1.WsSql.open(wsConf);
|
|
@@ -191,7 +267,7 @@ describe('TDWebSocket.Stmt()', () => {
|
|
|
191
267
|
console.log(result);
|
|
192
268
|
await connector.close();
|
|
193
269
|
});
|
|
194
|
-
test(
|
|
270
|
+
test("normal json tag BindParam", async () => {
|
|
195
271
|
let wsConf = new config_1.WSConfig(dsn, "100.100.100.100");
|
|
196
272
|
wsConf.setDb(db);
|
|
197
273
|
let connector = await wsSql_1.WsSql.open(wsConf);
|
|
@@ -231,7 +307,7 @@ describe('TDWebSocket.Stmt()', () => {
|
|
|
231
307
|
console.log(result);
|
|
232
308
|
await connector.close();
|
|
233
309
|
});
|
|
234
|
-
test(
|
|
310
|
+
test("normal json cn tag BindParam", async () => {
|
|
235
311
|
let wsConf = new config_1.WSConfig(dsn, "100.100.100.100");
|
|
236
312
|
wsConf.setDb(db);
|
|
237
313
|
let connector = await wsSql_1.WsSql.open(wsConf);
|
|
@@ -272,25 +348,25 @@ describe('TDWebSocket.Stmt()', () => {
|
|
|
272
348
|
await connector.close();
|
|
273
349
|
});
|
|
274
350
|
});
|
|
275
|
-
test(
|
|
351
|
+
test("test bind exception cases", async () => {
|
|
276
352
|
let wsConf = new config_1.WSConfig(dsn, "100.100.100.100");
|
|
277
353
|
let connector = await wsSql_1.WsSql.open(wsConf);
|
|
278
354
|
let stmt = await connector.stmtInit();
|
|
279
355
|
expect(stmt).toBeInstanceOf(wsStmt1_1.WsStmt1);
|
|
280
356
|
const params = stmt.newStmtParam();
|
|
281
357
|
const emptyArrayMethods = [
|
|
282
|
-
{ method:
|
|
283
|
-
{ method:
|
|
284
|
-
{ method:
|
|
285
|
-
{ method:
|
|
286
|
-
{ method:
|
|
287
|
-
{ method:
|
|
288
|
-
{ method:
|
|
289
|
-
{ method:
|
|
290
|
-
{ method:
|
|
291
|
-
{ method:
|
|
292
|
-
{ method:
|
|
293
|
-
{ method:
|
|
358
|
+
{ method: "setBoolean", name: "SetBooleanColumn" },
|
|
359
|
+
{ method: "setTinyInt", name: "SetTinyIntColumn" },
|
|
360
|
+
{ method: "setUTinyInt", name: "SetUTinyIntColumn" },
|
|
361
|
+
{ method: "setSmallInt", name: "SetSmallIntColumn" },
|
|
362
|
+
{ method: "setUSmallInt", name: "SetSmallIntColumn" },
|
|
363
|
+
{ method: "setInt", name: "SetIntColumn" },
|
|
364
|
+
{ method: "setUInt", name: "SetUIntColumn" },
|
|
365
|
+
{ method: "setBigint", name: "SetBigIntColumn" },
|
|
366
|
+
{ method: "setUBigint", name: "SetUBigIntColumn" },
|
|
367
|
+
{ method: "setFloat", name: "SetFloatColumn" },
|
|
368
|
+
{ method: "setDouble", name: "SetDoubleColumn" },
|
|
369
|
+
{ method: "setTimestamp", name: "SeTimestampColumn" },
|
|
294
370
|
];
|
|
295
371
|
emptyArrayMethods.forEach(({ method, name }) => {
|
|
296
372
|
expect(() => {
|
|
@@ -304,14 +380,14 @@ test('test bind exception cases', async () => {
|
|
|
304
380
|
}).toThrow(`${name} params is invalid!`);
|
|
305
381
|
});
|
|
306
382
|
expect(() => {
|
|
307
|
-
params.setBoolean([
|
|
308
|
-
}).toThrow(
|
|
383
|
+
params.setBoolean(["not boolean"]);
|
|
384
|
+
}).toThrow("SetTinyIntColumn params is invalid!");
|
|
309
385
|
expect(() => {
|
|
310
|
-
params.setTinyInt([
|
|
311
|
-
}).toThrow(
|
|
386
|
+
params.setTinyInt(["not number"]);
|
|
387
|
+
}).toThrow("SetTinyIntColumn params is invalid!");
|
|
312
388
|
expect(() => {
|
|
313
|
-
params.setBigint([
|
|
314
|
-
}).toThrow(
|
|
389
|
+
params.setBigint(["not bigint"]);
|
|
390
|
+
}).toThrow("SetTinyIntColumn params is invalid!");
|
|
315
391
|
await connector.close();
|
|
316
392
|
});
|
|
317
393
|
afterAll(async () => {
|