未验证 提交 717cea7c 编写于 作者: X xiaolei li 提交者: GitHub

<fix>[driver]:Nodejs fix cursor.close() failed (#11346)

* <fix>[driver]:Nodejs fix cursor.close() failed

* <fix>[driver]:Nodejs fix cursor.close() failed 2nd
上级 87fa1391
const taos = require('../tdengine');
const conn = taos.connect({
host: "localhost",
});
const cursor = conn.cursor();
function createDatabase() {
cursor.execute("CREATE DATABASE if not exists test_cursor_close");
cursor.execute("USE test_cursor_close");
}
function insertData() {
const lines = [
"meters,location=Beijing.Haidian,groupid=2 current=11.8,voltage=221,phase=0.28 1648432611249",
"meters,location=Beijing.Haidian,groupid=2 current=13.4,voltage=223,phase=0.29 1648432611250",
"meters,location=Beijing.Haidian,groupid=3 current=10.8,voltage=223,phase=0.29 1648432611249",
"meters,location=Beijing.Haidian,groupid=3 current=11.3,voltage=221,phase=0.35 1648432611250",
];
cursor.schemalessInsert(
lines,
taos.SCHEMALESS_PROTOCOL.TSDB_SML_LINE_PROTOCOL,
taos.SCHEMALESS_PRECISION.TSDB_SML_TIMESTAMP_MILLI_SECONDS
);
}
function query() {
let promise = cursor.query("select * from test_cursor_close.meters");
promise.execute().then(result => result.pretty()).catch(err => console.log(e));
}
function destructData() {
cursor.execute("drop database if exists test_cursor_close");
}
function main() {
try {
createDatabase();
insertData();
query();
destructData();
} finally {
cursor.close();
conn.close();
}
}
main();
\ No newline at end of file
......@@ -57,7 +57,7 @@ TDengineCursor.prototype.close = function close() {
if (this._connection == null) {
return false;
}
this._connection._clearResultSet();
// this._connection._clearResultSet();
this._reset_result();
this._connection = null;
return true;
......
......@@ -48,6 +48,7 @@ beforeAll(() => {
// Jest will wait for this promise to resolve before running tests.
afterAll(() => {
executeUpdate("drop database if exists node_test_db;");
c1.close();
conn.close();
});
......
......@@ -95,6 +95,7 @@ beforeAll(() => {
// Jest will wait for this promise to resolve before running tests.
afterAll(() => {
executeUpdate(`drop database if exists ${dbName};`);
c1.close();
conn.close();
});
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册