Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions firebase-firestore/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Unreleased

- [fixed] Fixed the cross-database document reference warning log naming the referenced document rather than the document containing the reference.

# 26.5.0

- [changed] Increased the default gRPC flow control window size from 64KB to 256KB to speed up large document reads, and added support for configuring this window size via `FirebaseFirestoreSettings.Builder.setGrpcFlowControlWindow()`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,8 @@ private Object convertReference(Value value) {
// TODO: Somehow support foreign references.
Logger.warn(
"DocumentSnapshot",
"Document %s contains a document reference within a different database "
+ "(%s/%s) which is not supported. It will be treated as a reference in "
"A document reference to %s refers to a different database "
+ "(%s/%s), which is not supported. It will be treated as a reference in "
+ "the current database (%s/%s) instead.",
key.getPath(),
refDatabase.getProjectId(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;
import org.robolectric.shadows.ShadowLog;

@RunWith(RobolectricTestRunner.class)
@Config(manifest = Config.NONE)
Expand Down Expand Up @@ -211,6 +212,33 @@ public void testConvertsResourceName() {
}
}

@Test
public void testConvertsResourceNameFromDifferentDatabase() {
ShadowLog.clear();
Value value =
Value.newBuilder()
.setReferenceValue("projects/other-project/databases/other-db/documents/foo/bar")
.build();
Object convertedValue = convertValue(value);
assertTrue(convertedValue instanceof DocumentReference);
DocumentReference docRef = (DocumentReference) convertedValue;
assertEquals(DocumentKey.fromPathString("foo/bar"), TestAccessHelper.referenceKey(docRef));

List<ShadowLog.LogItem> logs = ShadowLog.getLogsForTag("Firestore");
assertThat(logs).isNotEmpty();
boolean found = false;
for (ShadowLog.LogItem log : logs) {
if (log.msg.contains(
"A document reference to foo/bar refers to a different database (other-project/other-db)"
+ ", which is not supported. It will be treated as a reference in the current"
+ " database (projectId/(default)) instead.")) {
found = true;
break;
}
}
assertTrue("Expected warning log not found in " + logs, found);
}

@Test
public void testConvertsGeoPointValue() {
List<GeoPoint> testCases = asList(new GeoPoint(1.24, 4.56), new GeoPoint(-20, 100));
Expand Down
Loading