mirror of
https://github.com/n8n-io/n8n.git
synced 2024-12-25 04:34:06 -08:00
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:
parent
8bb7243c2d
commit
250175d066
|
@ -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);
|
||||
|
||||
|
|
|
@ -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 } },
|
||||
);
|
||||
|
||||
|
|
Loading…
Reference in a new issue