From 1e7fc86b180f9c68e4b7c0360b06b08088a186a7 Mon Sep 17 00:00:00 2001 From: Luke Becker Date: Fri, 29 Jan 2021 12:00:40 -0600 Subject: [PATCH 1/2] adding decimal support --- src/RDSData.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/RDSData.ts b/src/RDSData.ts index 76c5778..5c5a6b3 100644 --- a/src/RDSData.ts +++ b/src/RDSData.ts @@ -213,6 +213,9 @@ export class RDSData { case 'SERIAL': v.number = isNull ? undefined : record[c].longValue; break; + case 'DECIMAL': + v.number = isNull ? undefined : parseFloat(record[c].stringValue!); + break; case 'UUID': case 'TEXT': case 'CHAR': From 185b84f6deaa8bd25f6d9fd7f76eead1297c3d8c Mon Sep 17 00:00:00 2001 From: Luke Becker Date: Fri, 29 Jan 2021 13:21:30 -0600 Subject: [PATCH 2/2] fixing decimals getting stored as whole numbers --- src/RDSData.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/RDSData.ts b/src/RDSData.ts index 5c5a6b3..071b7ac 100644 --- a/src/RDSData.ts +++ b/src/RDSData.ts @@ -22,7 +22,7 @@ export interface RDSDataType { [x: string]: string | boolean | Buffer | null; }; } -export type RDSDataTypes = 'stringValue' | 'booleanValue' | 'longValue' | 'isNull' | 'blobValue' | undefined; +export type RDSDataTypes = 'stringValue' | 'booleanValue' | 'longValue' | 'isNull' | 'blobValue' | 'doubleValue' |undefined; export type RDSDataParameterValue = string | Buffer | boolean | number | null | undefined; export interface RDSDataParameters { @@ -122,6 +122,9 @@ export class RDSData { return 'booleanValue'; } if (t === 'number') { + if (val && val as number % 1 !== 0) { + return 'doubleValue'; + } return 'longValue'; } if (val === null) {