fix(Postgres Node): For select queries, empty result should be be replaced with {"success":true} (#6703)

* fix(Postgres Node): For select queries, empty result should be be replaced with `{"success":true}`

*  less checks

---------

Co-authored-by: Michael Kret <michael.k@radency.com>
This commit is contained in:
कारतोफ्फेलस्क्रिप्ट™ 2023-07-19 16:15:43 +02:00 committed by GitHub
parent 8bb7243c2d
commit 250175d066
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 3 deletions

View file

@ -17,6 +17,7 @@ export async function router(this: IExecuteFunctions): Promise<INodeExecutionDat
const credentials = await this.getCredentials('postgres');
const options = this.getNodeParameter('options', 0, {});
options.nodeVersion = this.getNode().typeVersion;
options.operation = operation;
const { db, pgp, sshClient } = await configurePostgres(credentials, options);

View file

@ -208,6 +208,7 @@ export function configureQueryRunner(
) {
return async (queries: QueryWithValues[], items: INodeExecutionData[], options: IDataObject) => {
let returnData: INodeExecutionData[] = [];
const emptyReturnData = options.operation === 'select' ? [] : [{ json: { success: true } }];
const queryBatching = (options.queryBatching as QueryMode) || 'single';
@ -220,7 +221,7 @@ export function configureQueryRunner(
});
})
.flat();
returnData = returnData.length ? returnData : [{ json: { success: true } }];
returnData = returnData.length ? returnData : emptyReturnData;
} catch (err) {
const error = parsePostgresError(node, err, queries);
if (!continueOnFail) throw error;
@ -247,7 +248,7 @@ export function configureQueryRunner(
);
const executionData = this.helpers.constructExecutionMetaData(
wrapData(transactionResult.length ? transactionResult : [{ success: true }]),
wrapData(transactionResult.length ? transactionResult : emptyReturnData),
{ itemData: { item: i } },
);
@ -274,7 +275,7 @@ export function configureQueryRunner(
);
const executionData = this.helpers.constructExecutionMetaData(
wrapData(transactionResult.length ? transactionResult : [{ success: true }]),
wrapData(transactionResult.length ? transactionResult : emptyReturnData),
{ itemData: { item: i } },
);