-
-
Notifications
You must be signed in to change notification settings - Fork 625
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
TypeCast seems doesnt work #948
Comments
Is there typical pure c way's to convert to bool? like !!var. |
yes, this is known problem. Unfortunately typeCast api is too low level and resullts for execurte come in different binary format, I haven't figured out yet good way of making typeCast work for execute with compatible api |
@sidorares ok, so, how convert BinaryRow to json obj? |
Just do it in your code that consumes data? Not very central, but usually you have some mapping function anyway data -> model or view |
So, i have only clear code. Without that. |
console.log(rows[rows.length-1]);
BinaryRow {
id: 1,
name: 'dsad',
surename: 'asdad',
fname: 'd',
login: 'abcd',
password: 'qwdqwd',
group: 1,
type: 's',
active: <Buffer 01>,
login_changed: <Buffer 00> } |
const lastRow = rows.slice(-1)
console.log(JSON.stringify({ ...lastRow, active: lastRow.actibe === 1, login_changed: lastRow.login_changed[0] === 1 }, null, 2)); |
Is that normal way? let payload = JSON.parse(JSON.stringify(rows[rows.length-1])); |
const lastRow = rows[0];
console.log(JSON.stringify({ ...lastRow, active: lastRow.active[0] === 1, login_changed: lastRow.login_changed[0] === 1 }, null, 2)); @sidorares thank's, that work perf. console.log(JSON.parse(JSON.stringify({ ...lastRow, active: lastRow.active[0] === 1, login_changed: lastRow.login_changed[0] === 1 }, null, 2))); |
no need for |
But i need it for let payload, no? let payload = JSON.parse(JSON.stringify({ ...lastRow, active: lastRow.active[0] === 1, login_changed: lastRow.login_changed[0] === 1 }));
delete payload.password; also const lastRow = rows.slice(-1)[0]; //right? |
const payload = { ...lastRow, active: lastRow.active[0] === 1, login_changed: lastRow.login_changed[0] === 1 }; to avoid const { password, ...payload } = { ...lastRow, active: lastRow.active[0] === 1, login_changed: lastRow.login_changed[0] === 1 }; |
Thx. |
Now, Whether the feature(typeCast) is supported ? |
I have the same issue. |
Doesn't call with execute.
dup: #649 #347
How i can turn to bool/int?
https://dev.mysql.com/doc/refman/8.0/en/bit-type.html
The text was updated successfully, but these errors were encountered: