diff --git a/.github/ISSUE_TEMPLATE/---bug-report.md b/.github/ISSUE_TEMPLATE/---bug-report.md index e84fbaca6a..b6ba026500 100644 --- a/.github/ISSUE_TEMPLATE/---bug-report.md +++ b/.github/ISSUE_TEMPLATE/---bug-report.md @@ -19,12 +19,7 @@ assignees: Nikhil-Nandagopal Good items to include here include: - Console / network logs from your browser - -### What you expected to happen -A clear and concise description of what you expected to happen. - -### Screenshots -If applicable, add screenshots to help explain your problem. +- Screenshots ### Important Details diff --git a/app/server/appsmith-plugins/mongoPlugin/src/main/java/com/external/plugins/MongoPlugin.java b/app/server/appsmith-plugins/mongoPlugin/src/main/java/com/external/plugins/MongoPlugin.java index 1a7279aeeb..32504c7779 100644 --- a/app/server/appsmith-plugins/mongoPlugin/src/main/java/com/external/plugins/MongoPlugin.java +++ b/app/server/appsmith-plugins/mongoPlugin/src/main/java/com/external/plugins/MongoPlugin.java @@ -118,8 +118,10 @@ public class MongoPlugin extends BasePlugin { // For the `findAndModify` command, we don't get the count of modifications made. Instead, we either // get the modified new value or the pre-modified old value (depending on the `new` field in the // command. Let's return that value to the user. - if (mongoOutput.containsKey(VALUE_STR)) { - result.setBody(new JSONObject().put(VALUE_STR, mongoOutput.get(VALUE_STR))); + if (outputJson.has(VALUE_STR)) { + result.setBody(objectMapper.readTree( + cleanUp(new JSONObject().put(VALUE_STR, outputJson.get(VALUE_STR))).toString() + )); } //The json contains key "cursor" when find command was issued and there are 1 or more results. In case diff --git a/app/server/appsmith-plugins/mongoPlugin/src/test/java/com/external/plugins/MongoPluginTest.java b/app/server/appsmith-plugins/mongoPlugin/src/test/java/com/external/plugins/MongoPluginTest.java index ccd2b75ca8..6ce185ae6c 100644 --- a/app/server/appsmith-plugins/mongoPlugin/src/test/java/com/external/plugins/MongoPluginTest.java +++ b/app/server/appsmith-plugins/mongoPlugin/src/test/java/com/external/plugins/MongoPluginTest.java @@ -7,6 +7,7 @@ import com.appsmith.external.models.DatasourceConfiguration; import com.appsmith.external.models.Endpoint; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.node.ArrayNode; +import com.fasterxml.jackson.databind.node.ObjectNode; import com.mongodb.MongoClient; import com.mongodb.client.MongoCollection; import org.bson.Document; @@ -38,6 +39,7 @@ public class MongoPluginTest { @ClassRule public static GenericContainer mongoContainer = new GenericContainer("mongo:4.2.0") .withExposedPorts(27017); + private JsonNode value; @Before public void setUp() { @@ -172,6 +174,11 @@ public class MongoPluginTest { assertNotNull(result); assertTrue(result.getIsExecutionSuccess()); assertNotNull(result.getBody()); + value = ((ObjectNode) result.getBody()).get("value"); + assertNotNull(value); + assertEquals("M", value.get("gender").asText()); + assertEquals("Alden Cantrell", value.get("name").asText()); + assertEquals(30, value.get("age").asInt()); }) .verifyComplete(); } @@ -200,8 +207,8 @@ public class MongoPluginTest { final JsonNode node = body.get(0); assertTrue(node.get("_id").isTextual()); assertTrue(node.get("luckyNumber").isNumber()); - assertEquals(node.get("dob").asText(), "2018-12-31T00:00:00Z"); - assertEquals(node.get("netWorth").toString(), "123456.789012"); + assertEquals("2018-12-31T00:00:00Z", node.get("dob").asText()); + assertEquals("123456.789012", node.get("netWorth").toString()); }) .verifyComplete(); }