From 94ebc7e8dea93df0246678aa8842055b850f9774 Mon Sep 17 00:00:00 2001 From: Russell Wheatley Date: Thu, 9 Jul 2020 17:54:19 +0100 Subject: [PATCH] chore(firestore): remove check that each read document also needs to be written for a transaction (#3915) * chore(firestore): rm transaction read/write need * tests(firestore): rm unnecessary test [publish] --- packages/firestore/e2e/Transaction.e2e.js | 16 ---------------- .../firestore/lib/FirestoreTransactionHandler.js | 11 ----------- 2 files changed, 27 deletions(-) diff --git a/packages/firestore/e2e/Transaction.e2e.js b/packages/firestore/e2e/Transaction.e2e.js index cb49d5cb..ba013e76 100644 --- a/packages/firestore/e2e/Transaction.e2e.js +++ b/packages/firestore/e2e/Transaction.e2e.js @@ -86,22 +86,6 @@ describe('firestore.Transaction', () => { } }); - it('should throw if get command is called with no writes', async () => { - const docRef = firebase.firestore().doc('v6/foo'); - - try { - await firebase.firestore().runTransaction(t => { - return t.get(docRef); - }); - return Promise.reject(new Error('Did not throw an Error.')); - } catch (error) { - error.message.should.containEql( - 'Every document read in a transaction must also be written', - ); - return Promise.resolve(); - } - }); - it('should get a document and return a DocumentSnapshot', async () => { const docRef = firebase.firestore().doc('v6/transactions/transaction/get-delete'); await docRef.set({}); diff --git a/packages/firestore/lib/FirestoreTransactionHandler.js b/packages/firestore/lib/FirestoreTransactionHandler.js index 305337b8..82bead23 100644 --- a/packages/firestore/lib/FirestoreTransactionHandler.js +++ b/packages/firestore/lib/FirestoreTransactionHandler.js @@ -99,17 +99,6 @@ export default class FirestoreTransactionHandler { // native emits that the transaction is final transaction._pendingResult = pendingResult; - if ( - transaction._calledGetCount > 0 && - transaction._calledGetCount !== transaction._commandBuffer.length - ) { - return meta.reject( - new Error( - 'firebase.firestore().runTransaction() Every document read in a transaction must also be written.', - ), - ); - } - // send the buffered update/set/delete commands for native to process return this._firestore.native.transactionApplyBuffer(id, transaction._commandBuffer); }