From 0db4c82cc02b4c9a846846c3579f4bfe5d83463d Mon Sep 17 00:00:00 2001 From: Mark Servidio Date: Mon, 9 Jan 2023 14:11:43 -0500 Subject: [PATCH] Update dataManager.js (#665) --- api/v1/src/datasets/dataManager.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/api/v1/src/datasets/dataManager.js b/api/v1/src/datasets/dataManager.js index 59b3a4da3..0db29edea 100644 --- a/api/v1/src/datasets/dataManager.js +++ b/api/v1/src/datasets/dataManager.js @@ -572,6 +572,12 @@ async function createView(view, overrideSql) { let viewCreated = createViewResult && createViewResult.success; console.log("Authorizing view objects for access from other datasets"); + + // https://github.com/GoogleCloudPlatform/datashare-toolkit/issues/655 + if (view.accessControl && view.accessControl.enabled === true && cfg.cdsDatasetId !== view.datasetId) { + await bigqueryUtil.shareAuthorizeView(cfg.cdsDatasetId, view.projectId, view.datasetId, view.name, viewCreated); + } + if (Object.prototype.hasOwnProperty.call(view, 'source') && view.source !== null) { let source = view.source; // https://github.com/GoogleCloudPlatform/datashare-toolkit/pull/409 @@ -581,9 +587,6 @@ async function createView(view, overrideSql) { // but have access to one or more tables or views, in which case authorizing views at the dataset level is required // if and when selecting data from another object within the same dataset for which a user does not have direct permission. await bigqueryUtil.shareAuthorizeView(source.datasetId, view.projectId, view.datasetId, view.name, viewCreated); - if (view.accessControl && view.accessControl.enabled === true && cfg.cdsDatasetId !== view.datasetId) { - await bigqueryUtil.shareAuthorizeView(cfg.cdsDatasetId, view.projectId, view.datasetId, view.name, viewCreated); - } } else if (Object.prototype.hasOwnProperty.call(view, 'custom') && view.custom !== null) { // Custom sql