Browse Source

refactor: convert decimal value in mysql to float

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/6470/head
Pranav C 1 year ago
parent
commit
ff8fc5ec9c
  1. 8
      packages/nocodb/src/utils/common/NcConnectionMgrv2.ts

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

@ -66,13 +66,19 @@ export default class NcConnectionMgrv2 {
connection: { connection: {
...defaultConnectionConfig, ...defaultConnectionConfig,
...connectionConfig.connection, ...connectionConfig.connection,
typeCast(_field, next) { typeCast(field, next) {
const res = next(); const res = next();
if (res instanceof Buffer) { if (res instanceof Buffer) {
return [...res] return [...res]
.map((v) => ('00' + v.toString(16)).slice(-2)) .map((v) => ('00' + v.toString(16)).slice(-2))
.join(''); .join('');
} }
// mysql `decimal` datatype returns value as string, convert it to float number
if (field.type == 'NEWDECIMAL') {
return res && parseFloat(res);
}
return res; return res;
}, },
}, },

Loading…
Cancel
Save