diff --git a/packages/nodes-base/nodes/Postgres/Postgres.node.ts b/packages/nodes-base/nodes/Postgres/Postgres.node.ts index 2082185ed9..662768d28f 100644 --- a/packages/nodes-base/nodes/Postgres/Postgres.node.ts +++ b/packages/nodes-base/nodes/Postgres/Postgres.node.ts @@ -228,6 +228,24 @@ export class Postgres implements INodeType { default: 'multiple', description: 'The way queries should be sent to database. Can be used in conjunction with Continue on Fail. See the docs for more examples', }, + { + displayName: 'Output Large-Format Numbers As', + name: 'largeNumbersOutput', + type: 'options', + options: [ + { + name: 'Numbers', + value: 'numbers', + }, + { + name: 'Text', + value: 'text', + description: 'Use this if you expect numbers longer than 16 digits (otherwise numbers may be incorrect)', + }, + ], + hint: 'Applies to NUMERIC and BIGINT columns only', + default: 'text', + }, { displayName: 'Query Parameters', name: 'queryParams', @@ -250,9 +268,19 @@ export class Postgres implements INodeType { async execute(this: IExecuteFunctions): Promise { const credentials = await this.getCredentials('postgres'); + const largeNumbersOutput = this.getNodeParameter('additionalFields.largeNumbersOutput', 0, '') as string; const pgp = pgPromise(); + if (largeNumbersOutput === 'numbers') { + pgp.pg.types.setTypeParser(20, (value: string) => { + return parseInt(value, 10); + }); + pgp.pg.types.setTypeParser(1700, (value: string) => { + return parseFloat(value); + }); + } + const config: IDataObject = { host: credentials.host as string, port: credentials.port as number,