From b84750a8ba3c7a8cb90abe49557913b191b9bd0d Mon Sep 17 00:00:00 2001 From: Alka Trivedi Date: Mon, 15 Apr 2024 13:03:27 +0530 Subject: [PATCH] fix: presubmit error --- samples/insert-query-with-get-trasanction.js | 8 ++++++-- src/database.ts | 10 ++++++---- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/samples/insert-query-with-get-trasanction.js b/samples/insert-query-with-get-trasanction.js index 2bd64389b..fc735b88b 100644 --- a/samples/insert-query-with-get-trasanction.js +++ b/samples/insert-query-with-get-trasanction.js @@ -19,7 +19,8 @@ async function main(instanceId, databaseId, projectId) { // [START spanner_insert_query_with_get_transaction] // Imports the Google Cloud client library. - const {Spanner} = require('@google-cloud/spanner'); + const {Spanner, protos} = require('@google-cloud/spanner'); + const Priority = protos.google.spanner.v1.RequestOptions.Priority; /** * TODO(developer): Uncomment the following lines before running the sample. @@ -40,7 +41,10 @@ async function main(instanceId, databaseId, projectId) { const options = { optimisticLock: true, - }; + requestOptions: { + priority: Priority.PRIORITY_LOW, + }, + } const promise = await database.getTransaction(options); const transaction = promise[0]; diff --git a/src/database.ts b/src/database.ts index e459763b2..b375706a9 100644 --- a/src/database.ts +++ b/src/database.ts @@ -2014,10 +2014,12 @@ class Database extends common.GrpcServiceObject { ? (optionsOrCallback as GetTransactionOptions) : {}; this.pool_.getSession((err, session, transaction) => { - transaction!.requestOptions = Object.assign( - transaction!.requestOptions || {}, - options.requestOptions - ); + if(options.requestOptions) { + transaction!.requestOptions = Object.assign( + transaction!.requestOptions || {}, + options.requestOptions + ); + } if (options.optimisticLock) { transaction!.useOptimisticLock(); }