Skip to content

Commit b36d1e6

Browse files
authored
fix: fix sql order (#94)
* style: format code * fix: fix sql order * style: format code
1 parent be06771 commit b36d1e6

23 files changed

Lines changed: 134 additions & 99 deletions

.github/workflows/build.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ jobs:
3838
libgeos-dev libjansson-dev libsnappy-dev liblzma-dev libz-dev \
3939
zlib1g pkg-config libssl-dev gawk
4040
41-
- name: install TDengine
41+
- name: Install TDengine
4242
run: |
4343
cd TDengine
4444
mkdir debug
@@ -49,11 +49,11 @@ jobs:
4949
which taosd
5050
which taosadapter
5151
52-
- name: start taosd
52+
- name: Start taosd
5353
run: |
5454
nohup sudo taosd &
5555
56-
- name: start taosadapter
56+
- name: Start taosadapter
5757
run: |
5858
nohup sudo taosadapter &
5959
@@ -69,7 +69,7 @@ jobs:
6969
with:
7070
node-version: ${{ matrix.node-version }}
7171

72-
- name: test nodejs websocket
72+
- name: Test nodejs websocket
7373
working-directory: nodejs-connector/nodejs
7474
run: |
7575
export TDENGINE_CLOUD_URL=${{ secrets.TDENGINE_CLOUD_URL }}

nodejs/example/all_type_query.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { WSConfig } from "../src/common/config";
2-
import { sqlConnect, destroy, setLogLevel } from "../src";
2+
import { sqlConnect, destroy } from "../src";
33

44
let dsn = "ws://127.0.0.1:6041";
55
async function json_tag_example() {
@@ -29,8 +29,8 @@ async function json_tag_example() {
2929
let taosResult = await wsSql.exec(insertQuery);
3030
console.log(
3131
"Successfully inserted " +
32-
taosResult.getAffectRows() +
33-
" rows to example_json_tag.stb."
32+
taosResult.getAffectRows() +
33+
" rows to example_json_tag.stb."
3434
);
3535

3636
let sql = "SELECT ts, v, jt FROM example_json_tag.stb limit 100";
@@ -70,10 +70,10 @@ async function all_type_example() {
7070
// create table
7171
await wsSql.exec(
7272
"create table if not exists all_type_example.stb (ts timestamp, " +
73-
"int_col INT, double_col DOUBLE, bool_col BOOL, binary_col BINARY(100)," +
74-
"nchar_col NCHAR(100), varbinary_col VARBINARY(100), geometry_col GEOMETRY(100)) " +
75-
"tags(int_tag INT, double_tag DOUBLE, bool_tag BOOL, binary_tag BINARY(100)," +
76-
"nchar_tag NCHAR(100), varbinary_tag VARBINARY(100), geometry_tag GEOMETRY(100));"
73+
"int_col INT, double_col DOUBLE, bool_col BOOL, binary_col BINARY(100)," +
74+
"nchar_col NCHAR(100), varbinary_col VARBINARY(100), geometry_col GEOMETRY(100)) " +
75+
"tags(int_tag INT, double_tag DOUBLE, bool_tag BOOL, binary_tag BINARY(100)," +
76+
"nchar_tag NCHAR(100), varbinary_tag VARBINARY(100), geometry_tag GEOMETRY(100));"
7777
);
7878

7979
console.log("Create stable all_type_example.stb successfully");
@@ -85,8 +85,8 @@ async function all_type_example() {
8585
let taosResult = await wsSql.exec(insertQuery);
8686
console.log(
8787
"Successfully inserted " +
88-
taosResult.getAffectRows() +
89-
" rows to all_type_example.stb."
88+
taosResult.getAffectRows() +
89+
" rows to all_type_example.stb."
9090
);
9191

9292
let sql = "SELECT * FROM all_type_example.stb limit 100";

nodejs/example/all_type_stmt.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,10 @@ async function all_type_example() {
8080
// create table
8181
await wsSql.exec(
8282
"create table if not exists stb (ts timestamp, " +
83-
"int_col INT, double_col DOUBLE, bool_col BOOL, binary_col BINARY(100)," +
84-
"nchar_col NCHAR(100), varbinary_col VARBINARY(100), geometry_col GEOMETRY(100)) " +
85-
"tags(int_tag INT, double_tag DOUBLE, bool_tag BOOL, binary_tag BINARY(100)," +
86-
"nchar_tag NCHAR(100), varbinary_tag VARBINARY(100), geometry_tag GEOMETRY(100));"
83+
"int_col INT, double_col DOUBLE, bool_col BOOL, binary_col BINARY(100)," +
84+
"nchar_col NCHAR(100), varbinary_col VARBINARY(100), geometry_col GEOMETRY(100)) " +
85+
"tags(int_tag INT, double_tag DOUBLE, bool_tag BOOL, binary_tag BINARY(100)," +
86+
"nchar_tag NCHAR(100), varbinary_tag VARBINARY(100), geometry_tag GEOMETRY(100));"
8787
);
8888

8989
console.log("Create stable all_type_example.stb successfully");

nodejs/example/basicBatchTmq.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,7 @@ async function insert() {
6262
let wsSql = await sqlConnect(conf);
6363
for (let i = 0; i < 10000; i++) {
6464
await wsSql.exec(
65-
`INSERT INTO d1001 USING ${stable} (location, groupId) TAGS ("California.SanFrancisco", 3) VALUES (NOW + ${i}a, ${
66-
10 + i
65+
`INSERT INTO d1001 USING ${stable} (location, groupId) TAGS ("California.SanFrancisco", 3) VALUES (NOW + ${i}a, ${10 + i
6766
}, ${200 + i}, ${0.32 + i})`
6867
);
6968
}

nodejs/example/basicTmq.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import { destroy, setLogLevel, sqlConnect, tmqConnect } from "../src";
55
const stable = "meters";
66
const db = "power";
77
const topics: string[] = ["topic_ws_map"];
8-
let dropTopic = `DROP TOPIC IF EXISTS ${topics[0]};`;
98
let configMap = new Map([
109
[TMQConstants.GROUP_ID, "gId_11"],
1110
[TMQConstants.CONNECT_USER, "root"],
@@ -31,8 +30,7 @@ async function Prepare() {
3130
await ws.exec(createTopic);
3231
for (let i = 0; i < 1000; i++) {
3332
await ws.exec(
34-
`INSERT INTO d1001 USING ${stable} (location, groupId) TAGS ("California.SanFrancisco", 3) VALUES (NOW + ${i}a, ${
35-
10 + i
33+
`INSERT INTO d1001 USING ${stable} (location, groupId) TAGS ("California.SanFrancisco", 3) VALUES (NOW + ${i}a, ${10 + i
3634
}, ${200 + i}, ${0.32 + i})`
3735
);
3836
}

nodejs/src/client/wsClient.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,6 @@ export class WsClient {
347347
this._wsConnector
348348
);
349349
this._wsConnector = undefined;
350-
// this._wsConnector.close();
351350
}
352351
}
353352

nodejs/src/client/wsConnector.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -210,9 +210,9 @@ export class WebSocketConnector {
210210
}
211211
logger.debug(
212212
"[wsClient.sendBinaryMsg()]===>" +
213-
reqId +
214-
action +
215-
message.byteLength
213+
reqId +
214+
action +
215+
message.byteLength
216216
);
217217
this._wsConn.send(message);
218218
} else {

nodejs/src/client/wsConnectorPool.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -67,28 +67,28 @@ export class WebSocketConnectionPool {
6767
if (connector) {
6868
logger.debug(
6969
"get connection success:" +
70-
Atomics.load(WebSocketConnectionPool.sharedArray, 0)
70+
Atomics.load(WebSocketConnectionPool.sharedArray, 0)
7171
);
7272
return connector;
7373
}
7474

7575
if (
7676
this._maxConnections != -1 &&
7777
Atomics.load(WebSocketConnectionPool.sharedArray, 0) >
78-
this._maxConnections
78+
this._maxConnections
7979
) {
8080
throw new TDWebSocketClientError(
8181
ErrorCode.ERR_WEBSOCKET_CONNECTION_ARRIVED_LIMIT,
8282
"websocket connect arrived limited:" +
83-
Atomics.load(WebSocketConnectionPool.sharedArray, 0)
83+
Atomics.load(WebSocketConnectionPool.sharedArray, 0)
8484
);
8585
}
8686
Atomics.add(WebSocketConnectionPool.sharedArray, 0, 1);
8787
logger.info(
8888
"getConnection, new connection count:" +
89-
Atomics.load(WebSocketConnectionPool.sharedArray, 0) +
90-
", connectAddr:" +
91-
connectAddr
89+
Atomics.load(WebSocketConnectionPool.sharedArray, 0) +
90+
", connectAddr:" +
91+
connectAddr
9292
);
9393
return new WebSocketConnector(url, timeout);
9494
} finally {
@@ -115,14 +115,14 @@ export class WebSocketConnectionPool {
115115
}
116116
logger.info(
117117
"releaseConnection, current connection count:" +
118-
connectors.length
118+
connectors.length
119119
);
120120
} else {
121121
Atomics.add(WebSocketConnectionPool.sharedArray, 0, -1);
122122
connector.close();
123123
logger.info(
124124
"releaseConnection, current connection status fail:" +
125-
Atomics.load(WebSocketConnectionPool.sharedArray, 0)
125+
Atomics.load(WebSocketConnectionPool.sharedArray, 0)
126126
);
127127
}
128128
} finally {
@@ -143,9 +143,9 @@ export class WebSocketConnectionPool {
143143
}
144144
logger.info(
145145
"destroyed connect:" +
146-
Atomics.load(WebSocketConnectionPool.sharedArray, 0) +
147-
" current count:" +
148-
num
146+
Atomics.load(WebSocketConnectionPool.sharedArray, 0) +
147+
" current count:" +
148+
num
149149
);
150150
Atomics.store(WebSocketConnectionPool.sharedArray, 0, 0);
151151
this.pool = new Map();

nodejs/src/client/wsEventCallback.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export class WsEventCallback {
3333
private static _instance?: WsEventCallback;
3434
private static _msgActionRegister: Map<MessageId, MessageAction> =
3535
new Map();
36-
private constructor() {}
36+
private constructor() { }
3737

3838
public static instance(): WsEventCallback {
3939
if (!WsEventCallback._instance) {
@@ -124,9 +124,9 @@ export class WsEventCallback {
124124
throw new TDWebSocketClientError(
125125
ErrorCode.ERR_WS_NO_CALLBACK,
126126
"no callback registered for fetch_block with req_id=" +
127-
msg.req_id +
128-
" action" +
129-
msg.action
127+
msg.req_id +
128+
" action" +
129+
msg.action
130130
);
131131
}
132132
}

nodejs/src/common/config.ts

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,27 +22,31 @@ export class WSConfig {
2222
public getToken(): string | undefined | null {
2323
return this._token;
2424
}
25+
2526
public setToken(token: string) {
2627
this._token = token;
2728
}
2829

2930
public getUser(): string | undefined | null {
3031
return this._user;
3132
}
33+
3234
public setUser(user: string) {
3335
this._user = user;
3436
}
3537

3638
public getPwd(): string | undefined | null {
3739
return this._password;
3840
}
41+
3942
public setPwd(pws: string) {
4043
this._password = pws;
4144
}
4245

4346
public getDb(): string | undefined | null {
4447
return this._db;
4548
}
49+
4650
public setDb(db: string) {
4751
this._db = db;
4852
}
@@ -55,18 +59,22 @@ export class WSConfig {
5559
this._url = url;
5660
}
5761

58-
public setTimeOut(ms: number) {
59-
this._timeout = ms;
60-
}
6162
public getTimeOut(): number | undefined | null {
6263
return this._timeout;
6364
}
64-
public setTimezone(timezone: string) {
65-
this._timezone = timezone;
65+
66+
public setTimeOut(ms: number) {
67+
this._timeout = ms;
6668
}
69+
6770
public getTimezone(): string | undefined | null {
6871
return this._timezone;
6972
}
73+
74+
public setTimezone(timezone: string) {
75+
this._timezone = timezone;
76+
}
77+
7078
public getMinStmt2Version() {
7179
return this._minStmt2Version;
7280
}

0 commit comments

Comments
 (0)