Browse Source

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

pull/7218/head
Pranav C 9 months ago committed by Ramesh Mane
parent
commit
23a8a409cc
  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) {
const res = next();
// mysql `bit` datatype returns value as Buffer, convert it to integer number
if (field.type == 'BIT' && res && res instanceof Buffer) {
return parseInt(
[...res].map((v) => ('00' + v.toString(16)).slice(-2)).join(''),
16,
);
// mysql - convert all other buffer values to hex string
// if `bit` datatype then convert it to integer number
if (res && res instanceof Buffer) {
const hex = [...res]
.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

Loading…
Cancel
Save