Skip to content

Commit 53c2d0a

Browse files
ryanmatsAce Nassri
authored and
Ace Nassri
committed
Updated readWriteTransaction to fix bug (GoogleCloudPlatform#317)
* Updated readWriteTransaction to fix bug Documentation at https://cloud.google.com/spanner/docs/transactions#rw_transaction_example says that second budget should be at least $300,000 for the transaction to proceed. I'm fixing this for Python / Node. Addresses bug #35360945. * Moved 300000 to minimumAmountToTransfer constant as per code review
1 parent dfc3639 commit 53c2d0a

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

spanner/transaction.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ function readWriteTransaction (instanceId, databaseId) {
100100
// at a specific point in time
101101
let transaction, firstBudget, secondBudget;
102102
const transferAmount = 200000;
103+
const minimumAmountToTransfer = 300000;
103104

104105
database.runTransaction()
105106
.then((results) => {
@@ -126,8 +127,8 @@ function readWriteTransaction (instanceId, databaseId) {
126127
console.log(`The second album's marketing budget: ${secondBudget}`);
127128

128129
// Makes sure the second album's budget is sufficient
129-
if (secondBudget < transferAmount) {
130-
throw new Error(`The second album's budget (${secondBudget}) is less than the transfer amount (${transferAmount}).`);
130+
if (secondBudget < minimumAmountToTransfer) {
131+
throw new Error(`The second album's budget (${secondBudget}) is less than the minimum required amount to transfer.`);
131132
}
132133
}),
133134

0 commit comments

Comments
 (0)