mirror of
https://github.com/n8n-io/n8n.git
synced 2025-03-05 20:50:17 -08:00
feat(Postgres Node): Improvement handling of large numbers (#3360)
* 🔨 fix * ⚡ ui update
This commit is contained in:
parent
c6e90d15b5
commit
9f908e7405
|
@ -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,
|
||||
|
|
Loading…
Reference in a new issue