fix(Google BigQuery Node): Location default to jobReference (#7354)

Github issue / Community forum post (link here to close automatically):
This commit is contained in:
Michael Kret 2023-10-06 14:16:55 +03:00 committed by GitHub
parent 1dfa052301
commit 97bb703d0a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 5 deletions

View file

@ -7,7 +7,7 @@ import type {
import { NodeOperationError, sleep } from 'n8n-workflow';
import { getResolvables, updateDisplayOptions } from '@utils/utilities';
import type { JobInsertResponse } from '../../helpers/interfaces';
import type { ResponseWithJobReference } from '../../helpers/interfaces';
import { prepareOutput } from '../../helpers/utils';
import { googleApiRequest } from '../../transport';
@ -205,7 +205,7 @@ export async function execute(this: IExecuteFunctions): Promise<INodeExecutionDa
body.useLegacySql = false;
}
const response: JobInsertResponse = await googleApiRequest.call(
const response: ResponseWithJobReference = await googleApiRequest.call(
this,
'POST',
`/v2/projects/${projectId}/jobs`,
@ -225,9 +225,10 @@ export async function execute(this: IExecuteFunctions): Promise<INodeExecutionDa
const jobId = response?.jobReference?.jobId;
const raw = rawOutput || (options.dryRun as boolean) || false;
const location = options.location || response.jobReference.location;
if (response.status?.state === 'DONE') {
const qs = options.location ? { location: options.location } : {};
const qs = { location };
const queryResponse: IDataObject = await googleApiRequest.call(
this,
@ -239,7 +240,7 @@ export async function execute(this: IExecuteFunctions): Promise<INodeExecutionDa
returnData.push(...prepareOutput.call(this, queryResponse, i, raw, includeSchema));
} else {
jobs.push({ jobId, projectId, i, raw, includeSchema, location: options.location });
jobs.push({ jobId, projectId, i, raw, includeSchema, location });
}
} catch (error) {
if (this.continueOnFail()) {

View file

@ -21,7 +21,7 @@ export type JobReference = {
location: string;
};
export type JobInsertResponse = {
export type ResponseWithJobReference = {
kind: string;
id: string;
jobReference: JobReference;