Skip to content

Commit 58a3f5a

Browse files
committed
Firestore: QueryTest.java: use a different Firestore instance instead of a WriteBatch to avoid affecting the local cache.
This fixes the bug introduced by #5167 where WriteBatch affects the local cache (which I didn't realize).
1 parent eafda53 commit 58a3f5a

File tree

1 file changed

+10
-13
lines changed
  • firebase-firestore/src/androidTest/java/com/google/firebase/firestore

1 file changed

+10
-13
lines changed

firebase-firestore/src/androidTest/java/com/google/firebase/firestore/QueryTest.java

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1077,17 +1077,18 @@ public void resumingAQueryShouldUseBloomFilterToAvoidFullRequery() throws Except
10771077
}
10781078
assertWithMessage("createdDocuments").that(createdDocuments).hasSize(100);
10791079

1080-
// Delete 50 of the 100 documents. Use a WriteBatch, rather than DocumentReference.delete(),
1081-
// to avoid affecting the local cache.
1080+
// Delete 50 of the 100 documents. Use a different Firestore instance to avoid affecting the
1081+
// local cache.
10821082
HashSet<String> deletedDocumentIds = new HashSet<>();
10831083
{
1084-
WriteBatch writeBatchForDocumentDeletes = collection.getFirestore().batch();
1084+
FirebaseFirestore db2 = testFirestore();
1085+
WriteBatch batch = db2.batch();
10851086
for (int i = 0; i < createdDocuments.size(); i += 2) {
1086-
DocumentReference documentToDelete = createdDocuments.get(i);
1087-
writeBatchForDocumentDeletes.delete(documentToDelete);
1087+
DocumentReference documentToDelete = db2.document(createdDocuments.get(i).getPath());
1088+
batch.delete(documentToDelete);
10881089
deletedDocumentIds.add(documentToDelete.getId());
10891090
}
1090-
waitFor(writeBatchForDocumentDeletes.commit());
1091+
waitFor(batch.commit());
10911092
}
10921093
assertWithMessage("deletedDocumentIds").that(deletedDocumentIds).hasSize(50);
10931094

@@ -1236,14 +1237,10 @@ public void bloomFilterShouldCorrectlyEncodeComplexUnicodeCharacters() throws Ex
12361237
}
12371238

12381239
// Delete one of the documents so that the next call to collection.get() will experience an
1239-
// existence filter mismatch. Use a WriteBatch, rather than DocumentReference.delete(), to avoid
1240-
// affecting the local cache.
1240+
// existence filter mismatch. Use a different Firestore instance to avoid affecting the local
1241+
// cache.
12411242
DocumentReference documentToDelete = collection.document("DocumentToDelete");
1242-
{
1243-
WriteBatch writeBatchForDocumentDeletes = collection.getFirestore().batch();
1244-
writeBatchForDocumentDeletes.delete(documentToDelete);
1245-
waitFor(writeBatchForDocumentDeletes.commit());
1246-
}
1243+
waitFor(testFirestore().document(documentToDelete.getPath()).delete());
12471244

12481245
// Wait for 10 seconds, during which Watch will stop tracking the query and will send an
12491246
// existence filter rather than "delete" events when the query is resumed.

0 commit comments

Comments
 (0)