feat(Postgres Node): Improvement handling of large numbers (#3360)

* 🔨 fix

*  ui update
This commit is contained in:
Michael Kret 2022-07-10 12:04:12 +03:00 committed by GitHub
parent c6e90d15b5
commit 9f908e7405
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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 <b>Continue on Fail</b>. See <a href="https://docs.n8n.io/nodes/n8n-nodes-base.postgres/">the docs</a> 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<INodeExecutionData[][]> {
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,