Browse Source

fix: if buffer type convert to hex value and convert to int only if type is bit

pull/7224/head
Pranav C 11 months ago
parent
commit
de2f55f2f0
  1. 16
      packages/nocodb/src/utils/common/NcConnectionMgrv2.ts

16
packages/nocodb/src/utils/common/NcConnectionMgrv2.ts

@ -69,12 +69,16 @@ export default class NcConnectionMgrv2 {
typeCast(field, next) { typeCast(field, next) {
const res = next(); const res = next();
// mysql `bit` datatype returns value as Buffer, convert it to integer number // mysql - convert all other buffer values to hex string
if (field.type == 'BIT' && res && res instanceof Buffer) { // if `bit` datatype then convert it to integer number
return parseInt( if (res && res instanceof Buffer) {
[...res].map((v) => ('00' + v.toString(16)).slice(-2)).join(''), const hex = [...res]
16, .map((v) => ('00' + v.toString(16)).slice(-2))
); .join('');
if (field.type == 'BIT') {
return parseInt(hex, 16);
}
return hex;
} }
// mysql `decimal` datatype returns value as string, convert it to float number // mysql `decimal` datatype returns value as string, convert it to float number

Loading…
Cancel
Save