Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename the $ref field to _ref in Firestore plugin #3135

Merged
merged 1 commit into from
Feb 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ private Object resultToMap(Object objResult, boolean isRoot) throws AppsmithPlug
// Individual document.
DocumentSnapshot documentSnapshot = (DocumentSnapshot) objResult;
Map<String, Object> resultMap = new HashMap<>();
resultMap.put("$ref", resultToMap(documentSnapshot.getReference()));
resultMap.put("_ref", resultToMap(documentSnapshot.getReference()));
if (documentSnapshot.getData() != null) {
for (final Map.Entry<String, Object> entry : documentSnapshot.getData().entrySet()) {
resultMap.put(entry.getKey(), resultToMap(entry.getValue(), false));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public void testGetSingleDocument() {
assertEquals("one", first.remove("name"));
assertFalse((Boolean) first.remove("isPlural"));
assertEquals(1L, first.remove("value"));
assertEquals(Map.of("id", "one", "path", "initial/one"), first.remove("$ref"));
assertEquals(Map.of("id", "one", "path", "initial/one"), first.remove("_ref"));
assertEquals(Collections.emptyMap(), first);
})
.verifyComplete();
Expand All @@ -139,7 +139,7 @@ public void testGetSingleDocument2() {
assertNotNull(doc.remove("dt"));
assertEquals("abc def", ((Blob) doc.remove("bytes")).toByteString().toStringUtf8());
assertNull(doc.remove("null-ref"));
assertEquals(Map.of("id", "two", "path", "initial/two"), doc.remove("$ref"));
assertEquals(Map.of("id", "two", "path", "initial/two"), doc.remove("_ref"));
assertEquals(Collections.emptyMap(), doc);
})
.verifyComplete();
Expand Down Expand Up @@ -168,7 +168,7 @@ public void testGetSingleDocument3() {
Map.of("path", "initial/one", "id", "one"),
Map.of("path", "initial/two", "id", "two")
), doc.remove("ref-list"));
assertEquals(Map.of("id", "inner-ref", "path", "initial/inner-ref"), doc.remove("$ref"));
assertEquals(Map.of("id", "inner-ref", "path", "initial/inner-ref"), doc.remove("_ref"));
assertEquals(Collections.emptyMap(), doc);
})
.verifyComplete();
Expand All @@ -195,7 +195,7 @@ public void testGetDocumentsInCollection() {
assertEquals("one", first.remove("name"));
assertFalse((Boolean) first.remove("isPlural"));
assertEquals(1L, first.remove("value"));
assertEquals(Map.of("id", "one", "path", "initial/one"), first.remove("$ref"));
assertEquals(Map.of("id", "one", "path", "initial/one"), first.remove("_ref"));
assertEquals(Collections.emptyMap(), first);

final Map<String, Object> second = results.stream().filter(d -> "two".equals(d.get("name"))).findFirst().orElse(null);
Expand All @@ -208,7 +208,7 @@ public void testGetDocumentsInCollection() {
assertNotNull(second.remove("dt"));
assertEquals("abc def", ((Blob) second.remove("bytes")).toByteString().toStringUtf8());
assertNull(second.remove("null-ref"));
assertEquals(Map.of("id", "two", "path", "initial/two"), second.remove("$ref"));
assertEquals(Map.of("id", "two", "path", "initial/two"), second.remove("_ref"));
assertEquals(Collections.emptyMap(), second);

final Map<String, Object> third = results.stream().filter(d -> "third".equals(d.get("name"))).findFirst().orElse(null);
Expand All @@ -223,7 +223,7 @@ public void testGetDocumentsInCollection() {
Map.of("path", "initial/one", "id", "one"),
Map.of("path", "initial/two", "id", "two")
), third.remove("ref-list"));
assertEquals(Map.of("id", "inner-ref", "path", "initial/inner-ref"), third.remove("$ref"));
assertEquals(Map.of("id", "inner-ref", "path", "initial/inner-ref"), third.remove("_ref"));
assertEquals(Collections.emptyMap(), third);
})
.verifyComplete();
Expand Down