Skip to content

Commit

Permalink
Rename the $ref field to _ref in Firestore plugin (#3135)
Browse files Browse the repository at this point in the history
(cherry picked from commit 198abbf)
  • Loading branch information
sharat87 committed Feb 22, 2021
1 parent 805e306 commit 276338a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
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

0 comments on commit 276338a

Please sign in to comment.