-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
no result by case when in count #62
Comments
Do you need more information? |
@pepit084 Has this ever worked for you? Or did it stop working after upgrade? Although your example works for me -- I would recommend avoiding the use of null in counts. -- avoid counting null with sum
sum(case hasSpecAttr when '1' then 1 else 0 end) cnt |
@jasonclake Thank you for trying! |
@pepit084 The problem is in DbStmt::fetchData -- Could qualify as a potential bug since SQLFetch returns "Success" (0) or "Success with info" (1) and fetchData is only looking for 0. But then again, it may have been on purpose, how would javascript know you had "success with info" Your original query returns with a 1 and I believe the "info" is a count with nulls eliminated message of some sort but I am not sure. I'll file another issue specifically about the Success vs Success with info return from SQLFetch and reference this issue. example program: const {dbconn, dbstmt} = require('idb-connector');
function runsqlp(sql, conn) {
return new Promise((resolve) => {
let statement = new dbstmt(conn);
console.log(`sql: ${sql}`);
statement.exec(sql, (result, error) => {
console.log(`result: ${JSON.stringify(result, null, ' ')}`);
console.log(`error: ${error}`);
statement.close();
resolve(result);
});
})
};
async function test(){
const connection = new dbconn();
connection.debug(true);
connection.conn('*LOCAL');
console.log('This works---------------------------------------------');
await runsqlp(`select name
, sum(case hasSpecAttr when '1' then 1 else 0 end) cnt
from jasontemp.article
group by name`, connection);
console.log('This does NOT work---------------------------------------------');
await runsqlp(`select name
, count(case hasSpecAttr when '1' then 1 else null end) cnt
from jasontemp.article
group by name`, connection);
connection.disconn();
connection.close();
}
test(); |
Fixed in v1.1.10. Close the issue. |
Hi there,
short example:
Following select works fine from any client I tested:
But if I execute this statement with idb-connector I get an empty result.
Can someone check this issue or am I doing something wrong?
Thank you!
OS-Version:
OS400 V7R3M0
Node-Version:
v10.15.0
npm-Version:
6.4.1
loopback-Version:
3.25.0
The text was updated successfully, but these errors were encountered: