未验证 提交 1a24394e 编写于 作者: H huili 提交者: GitHub

Merge pull request #4765 from taosdata/hotfix/TD-2302

Hotfix/td 2302
...@@ -367,11 +367,15 @@ CTaosInterface.prototype.fetchBlock = function fetchBlock(result, fields) { ...@@ -367,11 +367,15 @@ CTaosInterface.prototype.fetchBlock = function fetchBlock(result, fields) {
let offset = 0; let offset = 0;
for (let i = 0; i < fields.length; i++) { for (let i = 0; i < fields.length; i++) {
pdata = ref.reinterpret(pblock,8,i*8); pdata = ref.reinterpret(pblock,8,i*8);
pdata = ref.ref(pdata.readPointer()); if(ref.isNull(pdata.readPointer())){
if (!convertFunctions[fields[i]['type']] ) { blocks[i] = new Array();
throw new errors.DatabaseError("Invalid data type returned from database"); }else{
} pdata = ref.ref(pdata.readPointer());
blocks[i] = convertFunctions[fields[i]['type']](pdata, 1, fieldlens[i], offset, isMicro); if (!convertFunctions[fields[i]['type']] ) {
throw new errors.DatabaseError("Invalid data type returned from database");
}
blocks[i] = convertFunctions[fields[i]['type']](pdata, 1, fieldlens[i], offset, isMicro);
}
} }
return {blocks: blocks, num_of_rows:Math.abs(num_of_rows)} return {blocks: blocks, num_of_rows:Math.abs(num_of_rows)}
} }
...@@ -437,14 +441,18 @@ CTaosInterface.prototype.fetch_rows_a = function fetch_rows_a(result, callback, ...@@ -437,14 +441,18 @@ CTaosInterface.prototype.fetch_rows_a = function fetch_rows_a(result, callback,
} }
if (numOfRows2 > 0){ if (numOfRows2 > 0){
for (let i = 0; i < fields.length; i++) { for (let i = 0; i < fields.length; i++) {
if (!convertFunctions[fields[i]['type']] ) { if(ref.isNull(pdata.readPointer())){
throw new errors.DatabaseError("Invalid data type returned from database"); blocks[i] = new Array();
} }else{
let prow = ref.reinterpret(row,8,i*8); if (!convertFunctions[fields[i]['type']] ) {
prow = prow.readPointer(); throw new errors.DatabaseError("Invalid data type returned from database");
prow = ref.ref(prow); }
blocks[i] = convertFunctions[fields[i]['type']](prow, 1, fieldlens[i], offset, isMicro); let prow = ref.reinterpret(row,8,i*8);
//offset += fields[i]['bytes'] * numOfRows2; prow = prow.readPointer();
prow = ref.ref(prow);
blocks[i] = convertFunctions[fields[i]['type']](prow, 1, fieldlens[i], offset, isMicro);
//offset += fields[i]['bytes'] * numOfRows2;
}
} }
} }
callback(param2, result2, numOfRows2, blocks); callback(param2, result2, numOfRows2, blocks);
......
{ {
"name": "td2.0-connector", "name": "td2.0-connector",
"version": "2.0.1", "version": "2.0.4",
"description": "A Node.js connector for TDengine.", "description": "A Node.js connector for TDengine.",
"main": "tdengine.js", "main": "tdengine.js",
"scripts": { "scripts": {
......
...@@ -84,10 +84,19 @@ q.execute().then(function(r) { ...@@ -84,10 +84,19 @@ q.execute().then(function(r) {
r.pretty(); r.pretty();
}); });
// test query null value
c1.execute("create table if not exists td_connector_test.weather(ts timestamp, temperature float, humidity int) tags(location nchar(64))");
c1.execute("insert into t1 using weather tags('北京') values(now, 11.11, 11)");
c1.execute("insert into t1(ts, temperature) values(now, 22.22)");
c1.execute("insert into t1(ts, humidity) values(now, 33)");
c1.query('select * from test.t1', true).then(function (result) {
result.pretty();
});
var q = c1.query('select * from td_connector_test.weather'); var q = c1.query('select * from td_connector_test.weather');
console.log(q.query); console.log(q.query);
q.execute().then(function(r) { q.execute().then(function(r) {
//console.log(r);
r.pretty(); r.pretty();
}); });
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册