From 23a8a409ccfe7870edea9e7a7a30e63173821fd1 Mon Sep 17 00:00:00 2001 From: Pranav C Date: Wed, 13 Dec 2023 17:28:53 +0000 Subject: [PATCH] fix: if buffer type convert to hex value and convert to int only if type is bit --- .../nocodb/src/utils/common/NcConnectionMgrv2.ts | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/packages/nocodb/src/utils/common/NcConnectionMgrv2.ts b/packages/nocodb/src/utils/common/NcConnectionMgrv2.ts index 70a783b866..aca16dd7c2 100644 --- a/packages/nocodb/src/utils/common/NcConnectionMgrv2.ts +++ b/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