From 9f92a4d681918cb8d9f0d5b0bd322b93da0ba3ef Mon Sep 17 00:00:00 2001 From: Jonathan Bennetts Date: Tue, 13 Sep 2022 08:55:58 +0100 Subject: [PATCH] fix(googleBigQuery Node): fix empty response when creating records (#4056) --- .../Google/BigQuery/GoogleBigQuery.node.ts | 21 ++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/packages/nodes-base/nodes/Google/BigQuery/GoogleBigQuery.node.ts b/packages/nodes-base/nodes/Google/BigQuery/GoogleBigQuery.node.ts index e946ff4116..7e563429b0 100644 --- a/packages/nodes-base/nodes/Google/BigQuery/GoogleBigQuery.node.ts +++ b/packages/nodes-base/nodes/Google/BigQuery/GoogleBigQuery.node.ts @@ -190,13 +190,21 @@ export class GoogleBigQuery implements INodeType { `/v2/projects/${projectId}/datasets/${datasetId}/tables/${tableId}/insertAll`, body, ); - returnData.push(responseData); + + const executionData = this.helpers.constructExecutionMetaData( + this.helpers.returnJsonArray(responseData), + { itemData: { item: 0 } }, + ); + returnData.push(...executionData); } catch (error) { if (this.continueOnFail()) { - returnData.push({ json: { error: error.message } }); - } else { - throw new NodeApiError(this.getNode(), error); + const executionErrorData = this.helpers.constructExecutionMetaData( + this.helpers.returnJsonArray({ error: error.message }), + { itemData: { item: 0 } }, + ); + returnData.push(...executionErrorData); } + throw new NodeApiError(this.getNode(), error, { itemIndex: 0 }); } } else if (operation === 'getAll') { // ---------------------------------- @@ -251,7 +259,10 @@ export class GoogleBigQuery implements INodeType { ); } - responseData = simple ? simplify(responseData.rows, fields) : responseData.rows; + if (!returnAll) { + responseData = responseData.rows; + } + responseData = simple ? simplify(responseData, fields) : responseData; const executionData = this.helpers.constructExecutionMetaData( this.helpers.returnJsonArray(responseData),