Skip to content

Commit bc1f5c3

Browse files
committed
fix: turned all sql developer statements into one big statement to avoid rate limit errors
1 parent f345026 commit bc1f5c3

File tree

2 files changed

+15
-14
lines changed

2 files changed

+15
-14
lines changed

templates/ords-remix-jwt-sample/ords/RESTfulServices/grantSQLDeveloperRole.js

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,6 @@
1313
*/
1414
function grantSQLDeveloperRole(schema, object, objectAlias) {
1515
return `
16-
DECLARE
17-
L_PRIV_ROLES owa.vc_arr;
18-
L_PRIV_PATTERNS owa.vc_arr;
19-
L_PRIV_MODULES owa.vc_arr;
2016
BEGIN
2117
L_PRIV_ROLES( 1 ) := 'oracle.dbtools.autorest.any.schema';
2218
L_PRIV_ROLES( 2 ) := 'oracle.dbtools.role.autorest.${schema}.${object}';
@@ -32,9 +28,7 @@ function grantSQLDeveloperRole(schema, object, objectAlias) {
3228
P_DESCRIPTION => 'allow access to autoREST API',
3329
P_COMMENTS=> ''
3430
);
35-
COMMIT;
3631
END;
37-
/
3832
`;
3933
}
4034

templates/ords-remix-jwt-sample/ords/migrateScripts/autoRESTEnableObjects.js

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -97,19 +97,26 @@ async function autoRESTEnableObjects(schemaName, endpoint, basicAuth) {
9797
const statementsResponse = await postRequest(endpoint, autoRESTenableStatements, basicAuth);
9898
printResponse(statementsResponse);
9999
// Add the SQL Developer role to the objects that where autoREST Enabled.
100-
const sqlDevObjects = objectsToRESTEnable.filter((object) => object.isAutoRestAuth)
100+
const sqlDeveloperObjects = objectsToRESTEnable.filter((object) => object.isAutoRestAuth)
101101
.map((object) => grantSQLDeveloperRole(
102102
schemaName,
103103
object.objectName,
104104
object.objectAlias,
105105
));
106-
// Run the statements sequentially to avoid rate limiting errors from the DB
107-
await sqlDevObjects.reduce(async (previousPromise, sqlDevObject) => {
108-
await previousPromise;
109-
const statementResponse = await postRequest(endpoint, sqlDevObject, basicAuth);
110-
printResponse(statementResponse);
111-
return Promise.resolve();
112-
}, Promise.resolve());
106+
107+
const sqlDeveloperStatement = `
108+
DECLARE
109+
L_PRIV_ROLES owa.vc_arr;
110+
L_PRIV_PATTERNS owa.vc_arr;
111+
L_PRIV_MODULES owa.vc_arr;
112+
BEGIN
113+
${sqlDeveloperObjects.join(' ')}
114+
COMMIT;
115+
END;
116+
/
117+
`;
118+
const statementResponse = await postRequest(endpoint, sqlDeveloperStatement, basicAuth);
119+
printResponse(statementResponse);
113120
}
114121

115122
export default autoRESTEnableObjects;

0 commit comments

Comments
 (0)